understanding JasperReports and JRBeanCollectionDataSource

家住魔仙堡 提交于 2019-12-24 10:33:14

问题


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?


回答1:


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.




回答2:


I have not done jasper reports for a while but for templates with JRDataSources you dont use any sql hql in the reports and example is

http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/samples/DataSourceReport.jrxml

u pass in the datasource at the filling part of the execution



来源:https://stackoverflow.com/questions/894587/understanding-jasperreports-and-jrbeancollectiondatasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!