I am passing a List as paramter to Jasper as following.
Map<String, Object> model=new HashMap<>();
List<CustomObject> issues=new ArrayList<>();
issues.add(new CustomObject(1,"AIRPORT Services","XYZ","asdfa","asdf","asddf"));
issues.add(new CustomObject(1,"AIRPORT Services","XYZ","asdfa","asdf","asddf"));
model.put("issues",issues);
JasperPrint jasperPrint1 = JasperFillManager.fillReport(report, model, new JREmptyDataSource());
Now I am able to retrieve issuesList in jasper but I can't retrieve value inside CustomObject.
Following works and prints reference of CustomObject iterated using following
<textFieldExpression><![CDATA[$P{list}.get($V{ROW_INDEX})]]></textFieldExpression>
This throws exception when I want to access value of field inside Custom Object such as
<textFieldExpression><![CDATA[$P{list}.get($V{ROW_INDEX}).getCustomMethod()]]>
Exception:
Exception obtained is: The method getCustomMethod() is undefined for the type Object value = ((java.util.List)parameter_list.getValue()).get(((java.lang.Integer)variable_ROW_INDEX.getValue())).getCustomMethod(); //$JR_EXPR_ID=0$
With Help of Mike Answer at Print an arraylist content with JasperReports
I have iterated my Arraylist in jasper. Any help highly appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…