I have deep nested Set of strings in my model and I can't list them in my jasper report.
My model:
Profile:
List<Project> projectList;
Project:
Skill skills;
Skill:
Set<String> programmingLanguages;
I create report where Profile is main report, Skill is subreport but I can't get data from programmingLanguages Set in Skill subreport.
My jrxml files:
Profile report
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="jasper-test" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9f3515b2-a9bf-4194-ae0f-ceb8d4de1e70">
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"/>
<field name="projectList" class="java.util.List"/>
<detail>
<band height="299" splitType="Stretch">
<subreport>
<reportElement x="-2" y="148" width="555" height="51" uuid="f081f980-ea14-4434-9282-beebf515cb6c"/>
<subreportParameter name="SUBREPORT_DIR"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
($F{projectList})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "jasper-subreport-project.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
Project subreport:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="jasper-test" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9f3515b2-a9bf-4194-ae0f-ceb8d4de1e70">
<field name="skills" class="com.company.profilelist.model.Skill"/>
<detail>
<band height="299" splitType="Stretch">
<subreport>
<reportElement x="296" y="43" width="200" height="100" uuid="1084d612-8188-4dcc-8b09-6e534e76b879"/>
<subreportParameter name="skills">
<subreportParameterExpression><![CDATA[$F{skills}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "jasper-subreport-skills.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
Skill subreport:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="jasper-test" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9f3515b2-a9bf-4194-ae0f-ceb8d4de1e70">
<field name="programmingLanguages" class="java.util.Set">
<detail>
<band height="299" splitType="Stretch">
<textField>
<reportElement x="100" y="20" width="119" height="23" uuid="085d4a07-8dfa-4de4-b89d-6d915681fbc5"/>
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{programmingLanguages}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
I can't reach programmingLanguage field in skills subreport is there something I'm missing ?
try with following steps,
firstly, declare the skills
as a List in the project model
Project:
List<Skill> skills;
then, change the class
of field skills
to java.util.List
in the project report
<field name="skills" class="java.util.List"/>
finally, add dataSourceExpression
for skill sub report in the project report and remove the subreportParameterExpression
of skill sub report in the project report
<subreport>
<reportElement x="296" y="43" width="200" height="100" uuid="1084d612-8188-4dcc-8b09-6e534e76b879"/>
<subreportParameter name="skills"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{skills})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "jasper-subreport-skills.jasper"]]></subreportExpression>
</subreport>