Jump to content

Recommended Posts

Posted

I have this master report that passes 2 parameter to a subreport. One of the parameters is the value of a field ($F{foo}), and it's ok. The other parameter has the expression $V{bar}. So, it's the value of a variable. This one is always null at the subreport although it's non null and printable in the main report in the same band where I put the subreport.

For the variable to be printable in the main report I have to use "evaluation time = band". If I use "Now" it's always null.

So basically I'm passing this null expression to the subreport because I can't tell jasper that the expression should be evaluated at the end of the band, as I do with a text field.

Any ideas on how can I pass a parameter to a subreport when the expression is the evaluation of a variable? Or how can I control the evaluation time of the expression of the passed parameter?

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Posted

As far as I know, evaluation time is not expected with the subreport. For example, when we print page no x of y, we call the same variable but x evaluation time now & y evaluation time report, which means the last result will print. 
Now If we pass this page no to the subreport it always takes current data means evaluation time now data. If the subreport print on the first page it will print 1 if it calls on 2nd page it will print 2. 
 
I attached a report I think will help you. where I pass the field and calculative variable to the sub-report.
The output will look like this. 
Thanks 

Posted

There is a detail I didn't mention. The variable that I use in the expression of the parameter passed to the subreport is itself returned by another subreport. Later I saw in the docs that in these cases, the master variable that stores the subreport variable should be marked as "calculation=System". The lack of this setting was responsible for the variable being null most of the time. After I set it to "System" it took a value in the title band and kept it to the end, solving the original problem. Anyway, thanks for the explanation (with proof). I think this is the expected behavior. I mean, the passing of a variable to a subreport should evaluate when the report is being processed.

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