The most of the Reports of my application have a common page footer. Therefore, I'm trying to generate a subreport that contains this content to be embedded in all reports.
However, this common footer contains the pagination of the Report with the following format: Page X of Y where Y is the total number of pages of the Report.
I have defined this subreport passing the pagination as parameter from the master Report, but I have not been able to display the total number of pages.
I think that the problem is that when the total number of pages is evaluated in the master Report to be passed as parameter to the subreport, the master Report is not able to determine how many pages will have the report yet.
I have already read some posts about this problem and it seems that is not possible to solve it, but I would like to know if someone has found a solution
Miguel Angel Marina
As you would have noticed that in the template Page X of Y - 'Page X of' has an evaluation time of NOW where as 'Y ' has an evaluation time of 'Report'. This trigers the time when they are evaluated, in your case you are passing this value as parameter in the subreport and that is placed in the Page Footer, this will pass the current page number instead of the total count. This happens because the page footeris encountered at the end of every single page which demands the value of the Total Page, but total is failed to be generated as its evaluation time is Report so it passes the current page number of the master report.
Now another thing is that if you want to use scriptlets to determine the total page number that is also not possible beacause when the scriptlet events are fired, the JasperPrint onject which is created at the runtime of the JRXML is not yet final, so we can still not get the total number of pages.
So as far as I know, we cannot obtain the total number of pages of the report and pass it to any other subreport or element for manipulation.
Though, a workaround in you case can be -
You can place the page number portion in the main report and keep the rest in the subreport.
Hope that helps.