Skip to content

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

@jnehlmeier

Description

@jnehlmeier

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions