0
votes

I have a report created in jasperreports 2.0.4 using iReport. I have two subreports. These two subreports share the same jrxml. I'm passing the jrxml as the subreport's report expression in a parameter. I have this code for this parameter

<parameter name="SUB_EXP" class="net.sf.jasperreports.engine.JasperReport"/>

Everything works fine. The issue is with the two subreports datasource

The datasource of these subreport comes from the SAME list of POJOs passed as parameter

<parameter name="SUB_SRC" class="com.mycompany.myapplication.core.persistence.MyListDataSource"/>

Here are the subreport jrxml code for the two subreports

1st

<subreport>
    <reportElement positionType="Float" x="0" y="0" width="570" height="1"/>
    <dataSourceExpression>
        <![CDATA[$P{SUB_SRC}]]>
    </dataSourceExpression>
    <subreportExpression class="net.sf.jasperreports.engine.JasperReport">
        <![CDATA[$P{SUB_EXP}]]>
    </subreportExpression>
</subreport>

2nd

<subreport>
    <reportElement positionType="Float" x="0" y="1" width="570" height="1"/>
    <dataSourceExpression>
        <![CDATA[$P{SUB_SRC}]]>
    </dataSourceExpression>
    <subreportExpression class="net.sf.jasperreports.engine.JasperReport">               
        <![CDATA[$P{SUB_EXP}]]>
    </subreportExpression>
</subreport>

You see, the two subreports have the same code.

The weird thing is that, the two subreport shows, but the data for the first subreport is not complete, and those missing data is in the second subreport. The expected behavior is that, the two subreport should two same complete data.

Am I facing some sort of concurrency issue here? If someone could just verify...

1

1 Answers

0
votes

Just guessing here, but maybe you are seeing only the complete first subreport..? You can't use same datasource twice without rewinding it, see: How to use the same datasource twice in JasperReports/iReport