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

Value (variable) displayed in GroupFooter after upgrading from JasperReports API 6.3.1 to 6.7.0 is null. This happens on page 11/14 on the report. #51

Open
ghost opened this issue Feb 26, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 26, 2019

Details:

Variable has the following properties:

  • Reset type = GROUP
  • Increment Type = NONE
  • Calculation = FIRST

Issue occurs when after printing the GroupHeader on the 10th page there is not enough space to print the Detail band so the variables are recalculated.

The flow is something like:
In the JRVerticalFiller.fillDetail() the condition detailBand.getBreakHeight() > columnFooterOffsetY - offsetY in the while loop is false leading to JRVerticalFiller.fillColumnBand() being invoked.
When the detail is being is filled the JRPrintBand would overflow because one of the fields stretches. As the JRPrintBand will overflow it causes JRVerticalFiller.fillColumnBreak() to be invoked and the JRPrintBand to be refilled. After JRVerticalFiller.fillColumnBreak()
JRCalculator.recalculateVariables() is called.
This method sets the variables incremented value to the previous incremented value but as the variable was reset when the group changed the previous incremented value is null.

@ghost
Copy link
Author

ghost commented Feb 27, 2019

Below is a better description of the flow

JRVerticalFiller.fillReportContent()
    JRCalculator.estimateGroupRuptures() //This sets group as changed.
    JRCalculator.initializeVariables(ResetTypeEnum.GROUP, IncrementTypeEnum.GROUP); //sets variables previousIncrementedValue to NULL
    fillGroupHeaders(false); //no issues here
    fillDetail();
        calculator.calculateVariables(true); // sets variable value as expected. Variable isInitialized set to false.
        fillColumnBand(detailBand, JRExpression.EVALUATION_DEFAULT, !atLeastOneDetailBandPrinted); //band overflows
            JRCalculator.recalculateVariables(); //sets variable incremented value back to previous which is NULL. As variable is initialized the value is never incremented properly again.

@ghost
Copy link
Author

ghost commented Feb 27, 2019

Fixed the issue by updating the JRCalculator.recalculateVariables() method to be:

protected void recalculateVariables() throws JRException {
        if (variables != null) {
            for (JRFillVariable variable : variables) {
                variable.setIncrementedValue(variable.getPreviousIncrementedValue());

                if (variable.getResetTypeValue() == ResetTypeEnum.GROUP) {
                    JRFillGroup group = (JRFillGroup) variable.getResetGroup();
                    variable.setInitialized(group.hasChanged());
                }
            }
        }

        calculateVariables(false);
    }

@teodord
Copy link
Collaborator

teodord commented Mar 7, 2019

Hi,
Do you have a simple JRXML demonstrating this problem?
Thank you,
Teodor

@ghost
Copy link
Author

ghost commented Mar 11, 2019

@teodord ... I don't have any sample JRXML. We have a suite of integration tests we run after deploying any code and this is where the failure occurred. In terms of report layout we are just using the Column Header, Detail, Group Header and Group Footer bands.

Just to note our application builds a JasperDesign on the fly when we are executing a report. We don't save static JRXMLs

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

1 participant