passing JRCsvDataSource to a subreport

Hi,

I'd like to include a subreport using JRCsvDataSource in a master report's summary band. I compile both the reports and then fill the master one using

JasperFillManager.fillReportToStream(in, out, params, dataSource);

but the subreport doesn't show.

?? Any idea why that could be ??

I have already set the datasource expression of the subreport to $P{REPORT_DATA_SOURCE} so that it has it, but still...

Thanks, miro
miro's picture
88
Joined: Aug 2 2006 - 12:34am
Last seen: 17 years 2 months ago

2 Answers:

Hi,

Passing the same data source to the subreport is not a good idea. I'm not sure this is what you need to do.
Using subreports means you have some hierarchy in the data... something like parent-child tables in a relational database. The subreport should get its own data source instance, maybe reading from some other CVS file...
Hard to say without more details.

I hope this helps.
Teodor
teodord's picture
53502
Joined: Jun 30 2006 - 9:00am
Last seen: 2 hours 4 min ago
Hi Teodor,
thanks for the post. I will try to give you more details:
- my master report actually doesn't use the datasource. I need it only for the subreport. :) Therefore I have to pass somehow the parameter from the master to the subreport.
- with the command $P{REPORT_DATA_SOURCE}.toString in a text field i found out that the subreport gets the same object like the master.
- if I use the same subreport as a master report it works and the datasource is read, but this is not the case when it is a subreport.
- through some testing (using new JRDataSource($P{REPORT_DATA_SOURCE}) as the value for the Datasource Expression) I found this code snipplet:

value = (net.sf.jasperreports.engine.JRDataSource)(new JRDataSource(((net.sf.jasperreports.engine.JRDataSource)parameter_REPORT_DATA_SOURCE.getValue())));

I am wondering what parameter_REPORT_DATA_SOURCE.getValue() does when the class type of this parameter is JRDataSource and this interface doesn't have a getValue() method?

Thank you very much for answering and helping.
Best, Miro.
miro's picture
88
Joined: Aug 2 2006 - 12:34am
Last seen: 17 years 2 months ago
Feedback