JasperReports - Subreport-DataSource
Posted on December 1, 2011
How to provide the complete datasource of a report to the subreport.
In project I had the case that I had to pass the complete datasource of the parent report to a subreport.
JasperReports has a defined parameter REPORT_DATA_SOURCE that contains the current DataSource for the report. Unfortunately, it does not work if you try to pass the parameter directly as dataSourceExpression. For the subreport you need a new DataSource. For this the method cloneDataSource () is intended. This creates a clone of the Parent DataSource and can then be passed to the subreport.