我将一个List作为参数传递给Jasper,如下所示。
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());
现在我能够在jasper中检索issuesList但我无法在CustomObject中检索值。
以下工作和打印参考使用以下
迭代的CustomObject<textFieldExpression><![CDATA[$P{list}.get($V{ROW_INDEX})]]></textFieldExpression>
当我想访问Custom Object中的字段值(例如
)时抛出异常 <textFieldExpression><![CDATA[$P{list}.get($V{ROW_INDEX}).getCustomMethod()]]>
例外:
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$
在Print an arraylist content with JasperReports迈克答案的帮助下 我在碧玉中迭代了我的Arraylist。任何帮助高度赞赏。
答案 0 :(得分:2)
当我从Object
投射到CustomObject
时,这对我有用
遵循
<textFieldExpression><![CDATA[((com.custom.CustomObject)$P{flightIssues}.get($V{ROW_INDEX})).getCustomeMethod()]]></textFieldExpression>