danysabo Posted April 12, 2010 Share Posted April 12, 2010 I have two different jasper server reports with same jrxml resource file, and I want for them to use different logo. How can I accomplished that? Thanks a lot! Link to comment Share on other sites More sharing options...
danysabo Posted April 12, 2010 Author Share Posted April 12, 2010 Sorry this was mistake, I send same topic twice. Can someone delete this one? Link to comment Share on other sites More sharing options...
madarapuv Posted April 12, 2010 Share Posted April 12, 2010 you can use Print when expression tag. pass one parameter to jrxml based on the parameter using print when expression you can show or hide the image. Venkat. Link to comment Share on other sites More sharing options...
acidcube Posted April 12, 2010 Share Posted April 12, 2010 Or just have 2 files with different logos each one.besides a jrxml file its what.. like 300kb each Link to comment Share on other sites More sharing options...
danysabo Posted April 14, 2010 Author Share Posted April 14, 2010 acidcubeWrote: Or just have 2 files with different logos each one.besides a jrxml file its what.. like 300kb each Point is that I dont want to have two files, because they are both equal (only logo differ). I am just refferencing to same jrxml file inside both jasper reports. madarapuvWrote: you can use Print when expression tag. pass one parameter to jrxml based on the parameter using print when expression you can show or hide the image. I know that I can to use print when expresion, but how can I sent different parameters to report? Link to comment Share on other sites More sharing options...
madarapuv Posted April 14, 2010 Share Posted April 14, 2010 On what basis you want to print the different logo's. can you Please explain details. Venkat.Post Edited by madarapuv at 04/14/2010 15:15Post Edited by madarapuv at 04/14/2010 15:16 Link to comment Share on other sites More sharing options...
danysabo Posted April 14, 2010 Author Share Posted April 14, 2010 Ok, I will explain in details. I have two foders on Jasper server, each one for different user. Both user can access to only his Report Unit inside his folder. I set up two different datasources, one for every user. Since structure for both databases are same (only data differs), I can use same jrxml file for both user. Every user access only to his database. And everything is fine. I just want to set up different logo for every user.I hope it's clear now.Passing parameter will be fine (I am doing that when I'm calling jasperreport from java code), I just don't know how to perform that inside Jasper server.Thank you. Link to comment Share on other sites More sharing options...
madarapuv Posted April 14, 2010 Share Posted April 14, 2010 Create new parameter in jrxml file and in jasper server(input controll) based on the user assign the value to the parameter in java ex: if user 'A' login to application assign value 'a' to created parameter and if user 'B' login to application assign value 'b' to the same parameter. using this parameter value and printexpression tag you can show or hide the logo's. Venkat. Link to comment Share on other sites More sharing options...
danysabo Posted April 14, 2010 Author Share Posted April 14, 2010 I just don't know how to assign value to the parameter in java, since I'm not using java code.Maybe to set 'Optional JSP location' for input parameters? Link to comment Share on other sites More sharing options...
madarapuv Posted April 14, 2010 Share Posted April 14, 2010 How you calling the jasper report? are using hhtp request in such add the parameters in http request.ex: add the parameters like url¶meter1=value. Thanks,Venkat. Link to comment Share on other sites More sharing options...
danysabo Posted April 15, 2010 Author Share Posted April 15, 2010 User can log in to jasper server through browser using his credentials, and he can see only his report. When he press report link, report is generated and displayed (so, there is no direct http request).BTW, I create input controls inside Report Unit when user need to send some parameters. But in this case, user doesn't need to enter anything, I just need to send default value.So, my problem still persists.Thanks, anyway.Daniel Link to comment Share on other sites More sharing options...
mdahlman Posted April 15, 2010 Share Posted April 15, 2010 danysabo,Take a look at this sample report which displays the logged in user's name:/reports/samples/SalesByMonthThat example simply displays the user's name using "$P{LoggedInUser}.getFullName()". You could use an expression like this for your logo in an image field:"repo:/images/" + $P{LoggedInUser}.getUsername() + ".png"That should let you display a custom logo for each user.By the way, these are the methods available on LoggedInUser:String getUsername();String getFullName();String getEmailAddress();boolean isExternallyDefined();boolean isEnabled();Set getRoles();Date getPreviousPasswordChangeTime();List getAttributes(); Regards,Matt Link to comment Share on other sites More sharing options...
danysabo Posted April 16, 2010 Author Share Posted April 16, 2010 Thanks Matt for LoggedInUser parameter (I didn't know it exists). Is there some documentation (or javadoc, source code...) about that, and others similar parameters?There is problem when some user is admin. He can see both report units in both folders, but it still need to be different logos. Is there some solution for that? Link to comment Share on other sites More sharing options...
danysabo Posted April 16, 2010 Author Share Posted April 16, 2010 Also, I don't want to add new image when adding new user. It could be better to send some parameter based on report unit. Post Edited by danysabo at 04/16/2010 15:12 Link to comment Share on other sites More sharing options...
mdahlman Posted April 16, 2010 Share Posted April 16, 2010 "There is problem when some user is admin. He can see both report units in both folders, but it still need to be different logos."I don't understand the requirement. Which logos need to be different from which logos? I thought you needed a "different logo for every user". In that case you're all set. "Also, I don't want to add new image when adding new user. It could be better to send some parameter based on report unit."I'm not sure if there is a question lurking in those statements. If you don't want the logo based on the user, then I agree that you'll need some other parameter to decide what logo to show. Do you just want one report to always have one logo, but you want the other report (using the exact same .jrxml) to have a different logo? In that case you don't need LoggedInUser at all. You could just add logo1.png as a resource for report1 with the name "logo.png". Then add logo2.png as a resource for report2 with the name "logo.png".Regards,Matt Link to comment Share on other sites More sharing options...
lucianc Posted April 20, 2010 Share Posted April 20, 2010 Different follow-up at http://jasperforge.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=72963 Link to comment Share on other sites More sharing options...
danysabo Posted April 20, 2010 Author Share Posted April 20, 2010 @Matt,In most cases every user can access only his report, but it is not the case always. You are right, I want that every report unit have his separate logo. And your new proposal work. Thank you! And thanks to Lucian, he give me the same answer.PS. I tried that earlies, but that didn't work. It works now, I don't know what problem was. Thank you both, again! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now