Passing report_data_source to sub report (not working)

0

Hi!

I have a report with a json data source and a subreport(S1) that opens a nother subreport(S2).

The idea is that S1 is dynamic and is just passing the received data source to the S3.

I know for sure that this is working:

((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource()

But this limits S1 for passing only Json data sources, so I'm looking for a more generic way of passing the data source.

I tried to only send the $P{REPORT_DATA_SOURCE} to S1 and pass it to S2 but this is not working.

Any one a idea on how to pass data to the subreports without specifying that it's JSON?

nick_39's picture
15
Joined: Jun 4 2019 - 10:15pm
Last seen: 2 days 15 hours ago

Using a data source in a traditional way, all implementations of JRDataSource are typed (XML, JSON, etc.), so your findings are correct. The most 'generic' way I've used is JRBeanCollectionDataSource, but that's of type Java Bean Collection. I've also passed 'data' to subreports using parameters (in combination with a traditional datasource) of type Object, but again, those are java objects. Isn't it the case that the subreport receiving the datasource would need some concept of the data source type to process/display the data i.e. json, xml, etc.? In other words, what is s2 expecting?

darth_fader - 2 weeks 1 day ago

The thing is that S1 is working like a switch so its opening in some cases S2 and in some case it will open a different subreport S3. S2 and S3 know what they will receive xml of json but S1 is stupid and must just pass the data. I can do a parameter tht will proably work.

nick_39 - 1 week 5 days ago

Just making my question a bit more specific, when I run the report in jasperstudio I use a local data source JSON file. When I run the report in production we send a parameter REPORT_DATA with json and then: new java.io.ByteArrayInputStream($P{REPORT_DATA}.getBytes("UTF-8")). So in production we can pass the REPORT_DATA parameter to the subreports and all the data is there. But when we run the report localy the REPORT_DATA contains no data because of the local JSON file. How should we do this that local and in production we could run the report and see it with data?

nick_39 - 1 week 3 days ago

0 Answers:

No answers yet
Feedback