Reputation: 10281
I'm trying to work out how best to do reports with a chart then a table representing the same dataset. I need to overcome the positioning of the summary is at the bottom, so intend to use subreports and table-subreports. I am experimenting with two tables and a chart in one detail band.
If I set the datasourceexpression
for to $P{REPORT_DATA_SOURCE}
only the chart displays data (presumably the first subreport type item) and the tables are empty. Seems the data can be consumed only once?
If I use a Dataset to query the database it works however it executes the Query three times, once for each table/chart. That will be a massive overhead.
Obviously I am not doing this right but I cannot find any examples of using the same dataset more than once.
Upvotes: 10
Views: 9350
Reputation: 411
An alternative solution, cloning the dataset:
http://code.google.com/p/cloning/
Cloner cloner=new Cloner();
ArrayList clone = cloner.deepClone(getSomeArrayList());
final JRDataSource ds = new JRBeanCollectionDataSource(AnotherBean);
HashMap parameters = new HashMap();
parameters.put("PARAM_A", new JRBeanCollectionDataSource(getSomeArrayList()));
parameters.put("PARAM_B", new JRBeanCollectionDataSource(clone));
Upvotes: 0
Reputation: 10281
There is no simple answer so I have raised a feature request http://jasperforge.org/projects/jasperreports/tracker/view.php?id=5487
The suggested workarounds were:
Thanks to sanda aka shertage on the jasperforge forum for these suggestions.
Upvotes: 3