[英]How do I iterate over a collection that is in an object passed as parameter in a jasper report?
I have an object A that has as an instance variable a collection of object Bs. 我有一个对象A,该对象具有对象Bs的集合作为实例变量。 Example:
例:
public class A{
String name;
List<B> myList;
...
public List<B> getMyList(){
return myList;
}
...
}
I want an instance of A to be the only source of information the jasper report gets. 我希望A实例成为碧玉报告获得的唯一信息来源。 I am currently doing something like:
我目前正在做类似的事情:
A myObjectA = new A(...);
InputStream reportFile = MyPage.this.getClass().getResourceAsStream("test.jrxml");
HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put("objectA", myObjectA);
...
JasperReport report = JasperCompileManager.compileReport(reportFile);
JasperPrint print = JasperFillManager.fillReport(report, parameters, new JRBeanCollectionDataSource(myObjectA.getMyList()));
return JasperExportManager.exportReportToPdf(print);
thereby passing two sources of information : 从而传递两个 信息源 :
I want to pass one source of information only: objectA; 我只想传递一个 信息源 :objectA; and leave the data source as a JREmptyDataSource().
并将数据源保留为JREmptyDataSource()。 Is it possible to iterate over myList in the report?
是否可以遍历报告中的myList? Even if there is an empty data source?
即使有空的数据源?
More generally speaking: How do I iterate over the Bs in A by passing only A? 一般而言:如何通过仅传递A来遍历A中的B?
Thanks! 谢谢!
也许实现自己的JRDataSource(在Bs上进行迭代)更合适。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.