Hi guys,
first of all, amazing job! I just love JasperReports, and how it all integrates with ireport and JasperServer.
I have used this solution for building up a load testing reporting server, and until now, everything run just perfect.
Last week i started optimizing the reports, and i got myself in the following problem, for which i could not find a solution till now.
First of all, i am running Ireport and JasperServer 3.5.0
What i am trying to do is the following:
I have an input control in the repository. the type is "multi select query"
This query returns some id's from the database. (like 1,2,3,4,5,6...)
My first report uses this input control, and is the starting report. the user can select one id, or multiple, depending on what he wants to analyse.
Suppose i would like to see report 1 with id's 3,4 and 5.
Everything works flawless here.
I am now trying to do a drill down report, by sending the input control above as a collection.
Therefore, i have my item linking with the following parameters:
Hyperlink Type: ReportExecution
run_id: $P{run_id}
Where run_id is the input control, and is defined in the first and second report as a parameter of type " collection "
The query in the second report looks like this:
SELECT id,testrun_id FROM performance WHERE $X{IN,testrun_id,run_id} ORDER BY id
Now, when trying to run the second report from the first report, using the hyperlink, i can clearly see that the collection values are not passed in the url.
When opening the second report, the run_id isn't selected (as an input control) If i print out the value, using $P{run_id}.toString(), the value is null
I have tried this also with lists, still no result.
If i use a String parameter in the first report, and assign it the value $P{run_id}.toString(), and use this in the hyperlink parameter (as string of course), the url looks like this:
http://jasperserver:8080/........&string_run_id=[1,+2]
The notation is already unusable, so i cannot use this workaround.
Another thing that i tried, was assigning a local parameter, of type list, with the default expression of:
new ArrayList(Arrays.asList( new Integer[] {new Integer(25260), new Integer(25261)} ))
When i run the second report with this parameters, again, the values are not transmitted.
I see two problems here:
- Is it possible at all to send collections as parameters, and use them furtheron in a query, with expressions like $X(IN,val_to_compare,passed_val)
- If yes, should the values of the collections be visible in the url?
- How should a collection look like ? If i try putting values manually, it works with one value, like "&run_id=24", but any combination of multiple values, like "&run_id=24,25,26" will fail"
I gave this problem more than two days of my time, and i begin to think that there is a bug somewhere.
I also want to mention that collection parameters WORK in SUBREPORTS ( as i said,my problem is with drill-down reports)
Keep up the good work.
Hope somebody can answer my problem. all other forums and blogs did not.
Regards,
Akash
5 Answers:
Hi,
Answer me one thing, are these two seperate reports or report two is placed in the resources of report 1?
If the first is true, create a similar input control for report 2 named the same and with same properties.
Input controls not only fetch values from the selections but also let the values be passed from hyperlinks.
Hope this helps,
KKriplani
The following technique is working for me, for passing collection parameters in a way that works nicely with the $X{IN} query syntax and also the target report UI input controls (tested in version 8 community edition):
- Use a 'Reference' type hyperlink for the drilldown report, instead of Report Execution. A relative URL can work, such as
"flow.html?_flowId=viewReportFlow&reportUnit=/path/to/report"
- Construct the parameter assignment part of the URL by converting your collection with an expression such as:
"&P_Category=" + $P{P_Category}.toString().replace("[", "").replace("]","").replace(", ","&P_Category=")
Note this results in repeated assignments to a single parameter for every item in the collection, which in turn adds each item to the parameter collection in the target report.
So in the case of the original question, the expression would look something like:
"&run_id=" + $P{run_id}.toString().replace("[", "").replace("]","").replace(", ","&run_id=")
and would produce something like:
&run_id=24&run_id=25&run_id=26
The $P{run_id} parameter in the target report then contains 24, 25 and 26.