Reputation: 98
This question is about Jasper Reports.
Suppose I want to create a Jasper Report using JRBeanCollectionDataSource
like this ...
jasperPrint = JasperFillManager.fillReport(JRLoader.getInputStream(fileName), parameters, new JRBeanCollectionDataSource(aList));
And suppose that the PoJo I am using has a Property of type List.
How can I access
For example in the Jasper XML file:
...field name="?????" class="java.lang.String" ...
Thanks for your help ...
Upvotes: 2
Views: 11080
Reputation: 9410
If your data source has fields of type List (more generally, of type java.util.Collection), then you can use a Table or List or Subreport component to iterate through them. Use one of those elements and set its data source like this:
new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{myListField})
You could also add your own helper class with a static method to deal with these fields appropriately.
This comes up a lot with MongoDB. I wrote an article on Collections in JasperReports. It uses MongoDB as the data source... but it would apply equally well to your POJO data source.
Upvotes: 6