Jump to content
Changes to the Jaspersoft community edition download ×

Two reports with same JRXML file, different logo


danysabo

Recommended Posts

  • Replies 16
  • Created
  • Last Reply

Top Posters In This Topic

acidcube
Wrote:

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.

 

madarapuv
Wrote:

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

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

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

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

danysabo,

Take a look at this sample report which displays the logged in user's name:
/reports/samples/SalesByMonth

That 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

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

"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

@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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...