Jaspersoft Studio - How to pass parameters to 2 different subdatasets?

I have 2 bar charts in my report, each using 2 different subdatasets. My main query is something like "select * from user_levels" which is used only as a placeholder so that the main report can render the bar charts correctly, instead of displaying nothing.

My question is: how can I pass the same value/parameter at runtime into the 2 subdatasets? Does the parameter need to be only passed from the main query or can it be unrelated to the main query?
If anyone can please list out the steps specific to Jaspersoft Studio, I would be very grateful. I have spent at least 5 days on this so far.

Thanks for your time and help.

dollyd's picture
Joined: Dec 1 2013 - 12:38am
Last seen: 9 years 8 months ago


dollyd - 9 years 8 months ago

2 Answers:

Each dataset is independent; its fields are separated from the main dataset and also from other datasets and subdatasets.

There is a good tutorial on working with datasets in Jaspersoft Studio available here: http://community.jaspersoft.com/wiki/creating-charts-and-datasets-jasper...


ilona's picture
Joined: Aug 2 2012 - 11:06am
Last seen: 9 years 2 months ago

Thanks for the reply, Ilona!
I've seen that tutorial before. It was quite informative and helped me understand how subdatasets can be setup and used. But one thing missing in that is the use of parameters.
Now I am beginning to think that subdatasets do not work with parameters or we cannot pass parent report parameters into them. Every which way I tried to pass parameters into subdatasets, it didnt work for me at all. So, I had to change my original report to work with subreports instead and they work with parameters from parent report.

dollyd - 9 years 8 months ago

The value for sub-datasets parameters are set by using the dataset run, which is part of each element that makes use of a sub-dataset. The dataset run is used to set the datasource that will produce the data for the sub-dataset, and also the parameters. The value for each parameter is set with an expression in which is possible to use all the main dataset objects, including parameters. This means that you can use main-dataset parameters to set the value of sub-dataset parameters.


giulio's picture
Joined: Jan 2 2007 - 4:15pm
Last seen: 3 days 20 hours ago

Thanks for your response, Giulio!
Can you give me some code examples or direct me to tutorials that teach what you mentioned in your reply.
Conceptually it makes sense to me, but I am not sure how to go about coding all that. I am using Jaspersoft Studio.

dollyd - 9 years 8 months ago