Jasperreports-两个子报表,相同的jrxml,相同的pojo数据源 [英] Jasperreports - two subreports, same jrxml, same pojo datasource

查看:137
本文介绍了Jasperreports-两个子报表,相同的jrxml,相同的pojo数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用iReport在jasperreports 2.0.4中创建的报告.我有两个子报表.这两个子报表共享相同的jrxml.我将jrxml作为参数中的子报表的报表表达式传递.我有这个参数的代码

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

这些子报表的数据源来自作为参数传递的POJO的 SAME 列表

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"/>

这是两个子报表的子报表jrxml代码

Here are the subreport jrxml code for the two subreports

第一

<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>

第二

<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...

推荐答案

在这里只是猜测,但也许您只看到完整的第一个子报表.您不能在不回退的情况下两次使用相同的数据源,请参阅: 如何在JasperReports/iReport中两次使用同一数据源

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-两个子报表,相同的jrxml,相同的pojo数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆