Open ghost opened 5 years ago
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.
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);
}
Hi, Do you have a simple JRXML demonstrating this problem? Thank you, Teodor
@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
Details:
Variable has the following properties:
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 conditiondetailBand.getBreakHeight() > columnFooterOffsetY - offsetY
in thewhile
loop is false leading toJRVerticalFiller.fillColumnBand()
being invoked. When the detail is being is filled theJRPrintBand
would overflow because one of the fields stretches. As theJRPrintBand
will overflow it causesJRVerticalFiller.fillColumnBreak()
to be invoked and theJRPrintBand
to be refilled. AfterJRVerticalFiller.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.