Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation time "auto" does not always work correctly with variables and their reset types "page" / "group" #196

Open
jnehlmeier opened this issue Jun 18, 2021 · 2 comments

Comments

@jnehlmeier
Copy link

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 time now and the other has evaluation time report or group (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 type page) and TOTAL_PAGE_NUMBER (reset type report or group depending on report) and put them into a single textfield with evaluation time auto. 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.

  1. Extract attached zip file
  2. Open file evaluation-time-auto-bug.jrxml in jasper studio
  3. Create a CSV data adapter and use the file jasperreports_testdata.csv. Hit the button Get column names from the first row of the file and make sure to check skip the first line below in the other section. The wizard should detect 5 column names (two groups with id + data columns and a detail_data column)
  4. Now open the preview of the report and choose the created CSV data adapter to populate the preview.

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 1
  • traditional 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.

@teodord
Copy link
Collaborator

teodord commented Sep 24, 2021

I can explain why it works this way, but it would probably not help you.

i don't see any workaround yet.

@DougAtCordiance
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants