intive-FDV / DynamicJasper

Dynamic Reports using Jasper Reports
http://intive-fdv.github.io/DynamicJasper/
GNU Lesser General Public License v3.0
241 stars 128 forks source link

Last group footer label always incorrect when the group size is 1 #84

Open Spanner0jjm opened 5 years ago

Spanner0jjm commented 5 years ago

When adding a footer label to groups, when the last group in the report contains just one element, the footer label is always incorrect (the label from the penultimate group is repeated).

Since the CustomExpression class is an interface, there is no way to correct this behaviour.

Below I include an extract of a typical DJGroup definition which creates a footer label with a CustomExpression, and a screenshot of the result it produces. You can see that the last footer label is incorrect.

The error is consistently replicated when the last group contains just one element.

Typical DJGroup creation:

DJGroup g1 = gb1.setCriteriaColumn((PropertyColumn) columnCamara).setGroupLayout(GroupLayout.VALUE_IN_HEADER)
        .addFooterVariable(columnComisionTotal, DJCalculation.SUM, groupVariables).setFooterVariablesHeight(20)
        .setFooterLabel(new DJGroupLabel(new CustomExpression() {
            private static final long serialVersionUID = -6204511174702760074L;

            @Override
            public String getClassName() {
                return String.class.getName();
            }

            @Override
            public Object evaluate(Map fields, Map variables, Map parameters) {
                return "Total " + fields.get("camara");
            }
        }, groupVariablesLabel, LabelPosition.LEFT)).build();

Incorrect last footer: Ultimo grupo incorrecto Any help would be appreciated.

juanalvarezg commented 4 years ago

I was able to reproduce this and did some fixes... If you are familiar with JasperReport internals, this is a pain in the neck. Please try new versions to check if the problem is solved