I am using Jasper-Reports 5.2.0 and have a main Report containing 2 sub-reports.
I have a Model ReportData
which contains two attributes: List<Feld> felder
and List<Wert> werte
. The two sub-models contain multiple attributes with data to be displayed in a table.
So this is how I pass my Datasource to the sub-reports.
<subreport>
<reportElement x="0" y="28" width="553" height="51" uuid="502d9559-e6bf-49c8-a34c-ffb8916634cd"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F(werte)]]></dataSourceExpression>
<subreportExpression><![CDATA["werte_subreport.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="0" y="90" width="555" height="50" uuid="5e5b0287-5002-4e31-aa8f-afe36ea78827"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F(felder))]]></dataSourceExpression>
<subreportExpression><![CDATA["felder_subreport.jasper"]]></subreportExpression>
</subreport>
and this is how I fill my report (datasource is the Collection of ReportData
):
printable = JasperFillManager.fillReport(PropertyLoader.getSingleton().loadAsInputStream(REPORT_FOLDER + File.separatorChar + KONFIG_JASPER),parameters, datasource);
Somehow my values are not passed to the sub-reports and Jasper Reports is trying to use attributes as defaultWert
, which isn't part of the Class Wert
and should be displayed in the sub-report.
net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : defaultWert
Caused by: java.lang.NoSuchMethodException: Unknown property 'defaultWert' on class XXXXXXXXXXXXXXXXXXXXXX.model.ReportData'
I defined the two Lists werte
and felder
as fields of type java.util.List
in the Main Report and defined the attributes as for defaultWert
as fields of type String in the sub-reports. What am I doing wrong?
Thanks for your replies, I just found the problem... it was a stupid syntax mistake... it has to be $F{felder} instead of $F(felder) in my JRExpression... it ist working fine now!