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

Column with custom expression not getting called when generateJasperReport is called without params #104

Open binaryfields opened 3 years ago

binaryfields commented 3 years ago

Hello,

I have a Dynamic Report that generates Jasper Report using DynamicJasperHelper. One of the columns is using Custom Expression.

ColumnBuilder.getNew()
                .setTitle("Name")
                .setCustomExpression(new CustomExpression() {
                    @Override
                    public Object evaluate(Map fields, Map variables, Map parameters) {
                        return fields.get("lastname") + ", " + fields.get("firstname");
                    }
                    @Override
                    public String getClassName() {
                        return String.class.getName();
                    }
                })
                .setWidth(40)
                .build();
  1. When calling generateJasperReport and setting generatedParams to null instead of input params , the report will no longer fill in a column that uses setCustomExpression.. All other columns that use setColumnProperty work fine.

JasperReport jasperReport = DynamicJasperHelper.generateJasperReport(dynamicReport, layoutManager, null); JasperPrint print = JasperFillManager.fillReport(jasperReport, params, conn)

  1. The same dynamic report works properly when the same input params are provided to generateJasperReport and fillReport.

I was under the impression that params provided to generateJasperReport may be omitted if they are not needed/used by the layout.

Any help would be greatly appreciated.

Thanks -Sebastian

binaryfields commented 3 years ago

One more clarification, being able to omit generatedParams allows for caching of the generated jasper report so it greatly helps in production use case.

Another piece of information is that if the jasper report is generated from a dynamic report using one set of input params and the report is later on rendered/filled in with a different set of input params, the same issue occurs. All columns with the exception of the ones that use custom expression work fine.