问题
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 iRepor
t, 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:
- Make sure to put the project class-path in "Report Import Directives" in iReport
- 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.
- 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