Jump to content
Changes to the Jaspersoft community edition download ×

Using dynamic resource key name


cristic83

Recommended Posts

Hi guys,

I want to generate a report whose header is different depending on the data that's inside the report: e.g if I show data for a month then the header should be "Monthly report" and if the data is for a week the header should be "Weekly report". Of course, the header should be internationlized.

I tried to solve this by using a parameter named reportType that's passed to the report template and then in the report template do something like this for the report header:

$R{$P{reportType}+".report.title"}

This doesn't work; when I try to compile this(in iReport) I get the following error: Syntax on token "$R", Assignment Operator expected after this token. Is there a way how I can achieve this?

As a workaround, I could use the $P{reportType} parameter to contain the value of the resource bundle item that I nedd to display, but I don't want to do this because then if the resource bundle changes the references to it would have to be changed both in the report template and in the code.

Thanks,

Cristi

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

Try this workaround: create 2 identical text fields in your header (ie with the same x, y, width, height, style, etc), but with different printWhenExpressions and textFieldExpressions.
Depending on their printWhenExpression, one of these text fields will be printed out in monthly reports, the other one in the weekly reports.

Hope this helps,
sanda

Code:


Post Edited by shertage at 03/02/2011 13:45
Link to comment
Share on other sites

  • 1 month later...
  • 9 years later...

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...