Im trying to create a basic jasper report with JRBeanCollectionDataSource
. In there im having a list of objects inside the javabean.
public class Course {
private int id;
private List<Student> students;
}
Student object looks like
public class Student {
private String name;
private int id;
}
I want to print student information inside my report. This is how my jrxml looks like
<subDataset name="dataset1" uuid="09015d96-ad5a-4fed-aa9e-19d25e02e205">
<field name="students" class="java.util.List">
<fieldDescription><![CDATA[students]]></fieldDescription>
</field>
</subDataset>
<field name="id" class="java.lang.Integer"/>
<field name="students" class="java.util.List"/>
<field name="name" class="java.lang.String"/>
<componentElement>
<reportElement x="200" y="0" width="400" height="20"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="dataset1">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{students})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="20" width="400">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
But when i run this im getting
net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. Field not found : name
Report design not valid :
1. Field not found : name
Im a beginner to jasper reports can anyone please tell me what am i doing wrong here. Thanks