Jump to content
Changes to the Jaspersoft community edition download ×

Jasper Subreport Displays Only First List Item


smittygo3

Recommended Posts

I am trying to pass a list of elements into a subreport. The report looks fine, except only the first list element is passed to the subreport.

Here is the main report:

 

<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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3374c653-7baa-40d8-9495-e175cd074c32">
    <field name="val" class="java.lang.String"/>
    <field name="listItems" class="java.util.List"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <columnHeader>
        <band height="46" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="180" height="46" uuid="446c53b5-ab1c-4ad1-8196-1f67e42aa7c5"/>
                <textElement>
                    <font fontName="SansSerif" size="24" isBold="true"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{val}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="420" splitType="Stretch">
            <subreport>
                <reportElement x="270" y="10" width="230" height="410" uuid="66a07aff-c7bb-490a-ae69-c07c483294db"/>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{listItems})]]></dataSourceExpression>
                <subreportExpression><![CDATA["sub.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>

Here is the subreport:

    <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="sub" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bf57ed59-2e9c-4d81-ad67-7185e156940e">
        <field name="name" class="java.lang.String"/>
        <field name="value" class="java.lang.String"/>
        <background>
            <band splitType="Stretch"/>
        </background>
        <pageHeader>
            <band height="42" splitType="Stretch">
                <textField>
                    <reportElement x="30" y="5" width="100" height="30" uuid="a3f1b7e7-ce4f-40c0-806f-a98a541c7654"/>
                    <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="260" y="6" width="100" height="30" uuid="c909ee47-f820-4129-ac0d-b098563484ba"/>
                    <textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
                </textField>
            </band>
        </pageHeader>
    </jasperReport>

Inside the subreport, I can see the first name and value. However, no other values are displayed after that. What else needs to be added to ensure all list items are displayed? Any help would be greatly appreciated.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...