The JRBeanCollectionDataSource as you can see in api implements both JRDataSource and JRRewindableDataSource.
The JRDataSource
is a consumable datasource (only next()
method) but the JRRewindableDataSource
adds a moveFirst()
method which makes it possibile to rewind the datasource.
However, this is not simple to do in the jrxml file (the design file) and I would not recommend doing it.
The simplest solution in your case is that instead of passing a JRBeanCollectionDataSource
pass the List
(your summaryList
) and create the JRBeanCollectionDataSource
in side your jrxml as many times as you need.
Example
In java
paramsMap.put("statsData", summaryList);
In jrxml
<parameter name="statsData" class="java.util.List"/>
...
<subreportParameter name="statsData">
<subreportParameterExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{statsData})]]></subreportParameterExpression>
</subreportParameter>
...
Note for future readers: This subreport is particular it passes a datasource as a parameter (that will be used to populate a jr:table
in the subreport), normally you would pass the datasource in the <dataSourceExpression>