理解JasperReports和JRBeanCollectionDataSource [英] understanding JasperReports and JRBeanCollectionDataSource

查看:1775
本文介绍了理解JasperReports和JRBeanCollectionDataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我的代码中有我的 JasperReports 工作于我的 JRBeancollectionDataSource !我对某些事情只是有点困惑......当我在 iRepor t中设计报告时,我从查询创建字段,我可以做得很好,因为当我实际运行查询时,我使用了一个代码 JRBeanCollectionDataSource 那么报告中的hql是完全不相关的吗?

另外,我还有其他持久对象的List集合,我想要一个可以列出列表元素的子报表,但我不明白如何从 iReport 中引用这些子列表,以便让它在我处于码。我可以只从一个领域转到另一个领域吗?即一个名为属性的字段和子属性直接引用该属性作为properties.value?

解决方案

当使用JRBeancollectionDataSource时,我更喜欢做如下所示:


  1. 确保将项目class-path放入iReport的报表导入指令中

  2. 创建报告查询或子数据集查询时。打开Report Query对话框,选择下一个选项卡JavaBean data source,并记下bean的完整路径名。然后点击读取属性,它应该用getter读取所有字段。

  3. 选择所需的字段,然后单击添加所选字段。 b
    $ b

    您可以在报告中找到所有您选择为$ F(fieldName)的人。


    I now have my JasperReports working from my JRBeancollectionDataSource in my code! I am just a bit confused about some things...

    When I am designing reports in iReport, I create the fields from a query, which I can do fine and all, since when I am actually running the query I'm using a a code JRBeanCollectionDataSource and so is the hql in the report totally irrelevant at this point?

    Also, I have List collections of other persistent objects in the ones I'm fetching for the report and I want a subreport that can list the elements of the list, but I don't understand how to reference those from inside iReport to have it make sense when I'm in the code. Can I just refer from one field to another? ie, a field called properties and the subresport referencing that field directly as properties.value?

    解决方案

    When using JRBeancollectionDataSource i prefer to do the following:

    1. Make sure to put the project class-path in "Report Import Directives" in iReport
    2. When creating the report query or the subdataset query. Open the Report Query dialog, choose the next tab "JavaBean data source" and write down the full path name of the bean. Then click "Read attributes", it should read all fields with getters.
    3. Choose the fields you want and click Add Selected Fields.

    You will find all those you chose as $F(fieldName) in the report.

    这篇关于理解JasperReports和JRBeanCollectionDataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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