Subreport json datasource expression using main report parameter

Hi all,

I've been strruggling a while with this now. I have a main report with a parameter that I need to use in the subreport datasource expression. I need it to be a json datasource.

I can't find a way to do this.

Thanks in advance :)

 

pierre.ortalo's picture
Joined: Aug 16 2017 - 1:34am
Last seen: 4 years 7 months ago

Please post some sample JRXML files for us to work with.

narcism - 5 years 4 months ago

please post source code, s that we can use also.

sushobhan.b - 3 years 3 months ago

2 Answers:

Got it :)

I used the following datasSource expression for the subreports:

new net.sf.jasperreports.engine.data.JsonDataSource("http://34....Id=" + $P{Id}.toString(), "")

It creates a JSONDatasource object by calling its constructor and passes the url where to get the json (location argument of the constructor) , second argument is a query on returned data. A main report argument can be passed to the url as you can see.

Hope it helps anyone :)

pierre.ortalo's picture
Joined: Aug 16 2017 - 1:34am
Last seen: 4 years 7 months ago

How to pass usernam eand password along with url if i have basic authentication on URL

sushobhan.b's picture
Joined: Aug 22 2018 - 10:52pm
Last seen: 1 year 10 months ago
Feedback
randomness