Open jnehlmeier opened 3 years ago
I can explain why it works this way, but it would probably not help you.
i don't see any workaround yet.
The recommended approach to "Page X of Y" is to use $V{MASTER_CURRENT_PAGE}
for X with evaluationTime set to "Master" and ${MASTER_TOTAL_PAGES}
for Y also with evaluation time set to 'Master'.
Hi,
we have reports with a page footer containing the usual "page x of y" text which has traditionally been implemented using two textfields. Each of them contains
$V{PAGE_NUMBER}
with one textfield having evaluation timenow
and the other has evaluation timereport
orgroup
(depending on the report).Now we upgraded to Jasperreports 6.17.0 and thought that always managing two textfields is annoying since you can not nicely align them to the right (since you don't know the total number of pages and you have to reserve some unknown space to the right). So we used a different approach with a single textfield and evaluation time
auto
. I think this is the recommend way these days.So we created two variables
CURRENT_PAGE_NUMBER
(reset typepage
) andTOTAL_PAGE_NUMBER
(reset typereport
orgroup
depending on report) and put them into a single textfield with evaluation timeauto
. Both variables have expression$V{PAGE_NUMBER}
, no calculation function and no initial value.This mostly works but some of our reports produced wrong page numbers. Basically for a given group the amount of total pages was missing one page and on that last page of the group the current page number is null.
Reproduction example
evaluation-time-auto-bug.zip
I have attached an example jrxml + csv data file that reproduces the issue. The example contains both approaches described above so you can see the difference between both.
evaluation-time-auto-bug.jrxml
in jasper studiojasperreports_testdata.csv
. Hit the buttonGet column names from the first row of the file
and make sure to checkskip the first line
below in theother
section. The wizard should detect 5 column names (two groups with id + data columns and a detail_data column)You should now see 6 pages and the page numbers of the last two pages shown in the evaluation time
auto
textfield are wrong. The page numbers basically miss the last page:auto
approach: Page 1 of 1 => Page null of 1traditional approach: Page 1 of 2 => Page 2 of 2
I think the reason is that the second detail band is moved to a new page but the underlying model is not fully updated so that
$V{PAGE_NUMBER}
has a wrong value.In our real reports this issue does not only happen on the very last pages of the last group of the report but can happen on any group within the report. Basically whenever detail bands of the last page within a group have to be moved to a new page.