简体   繁体   English

Jasperreports-两个子报表,相同的jrxml,相同的pojo数据源

[英]Jasperreports - two subreports, same jrxml, same pojo datasource

I have a report created in jasperreports 2.0.4 using iReport. 我有一个使用iReport在jasperreports 2.0.4中创建的报告。 I have two subreports. 我有两个子报表。 These two subreports share the same jrxml. 这两个子报表共享相同的jrxml。 I'm passing the jrxml as the subreport's report expression in a parameter. 我在参数中将jrxml作为子报表的报表表达式传递。 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 这些子报表的数据源来自作为参数传递的POJO的SAME列表

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

Here are the subreport jrxml code for the two subreports 这是两个子报表的子报表jrxml代码

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... 如果有人可以验证...

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 您不能重复使用同一数据源而不回退,请参阅: 如何在JasperReports / iReport中两次使用同一数据源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM