Jasper Report with List or Collection of Pojos
jasper-reports
Solution
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.
Problem
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 - The individual items in this List, - and if this item is itself a Pojo access it's properties in Jasper Report XML file. For example in the Jasper XML file: ``` ...field name="?????" class="java.lang.String" ... ``` Thanks for your help ...