Suresh Kumar Suresh Kumar - 4 months ago 14
Java Question

How to populate Japser report For a list of objects where each object has a list of objects inside?

Object is like this

class jobVO{
...
List<taskVO> tasks;
...
}
class TaskVO{
String name;
...
}


I need to pass List to a jrxml and print.

I tried with subreports. but there I couldn't find a way to pass the params.
Also tried with collection datasource also. There the problem I found was need to mention the factory method. My requirement is to create this report dynamically.

Answer
created 2 subreports

<detail>
    <band height="60" splitType="Stretch">
        <subreport>
            <reportElement x="-19" y="34" width="560" height="26" uuid="7006626b-cfcb-4dcc-a1c8-3ef0f95e0440"/>
            <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{items})]]></dataSourceExpression>
            <subreportExpression><![CDATA["D:\\Root1\\WEB1\\src\\sub1.jasper"]]></subreportExpression>
        </subreport>
    </band>
</detail>