Issue:
Http url query string parameters, like firstname & hobby in the following url, can be used in JasperReports Server reports, even as inputs to the query-based input controls:
http://myserver.com/testpage.html?firstname=greg&hobby=fun
Resolution:
This example uses the foodmart sample database tables shipped with JasperReports Server. This example was created in 4.7.1.
Define the parameter for use within your JRXML:
<parameter name="position_param" class="java.lang.String"/>
For testing, my input parameter is in my main report query:
select * from employee where position_title = $P{position_param} limit 5
Within the web UI of your report, in the "Controls and Resources" page create the first input control with these characteristics:
Name is foo, single value, invisible or visible, text is the datatype.
Use these characteristics for your second input control created in the "Controls and Resources" page:
Name it position_param (name obviously has to match what we created in jrxml), singe select query, mandatory checkbox, and
In the query use: select position_title from employee where position_title = $P{foo}. Ensure position_title is returned in the values.
On the "Controls and Resources page ensure the "always prompt" is unchecked.
Execute your reports url with the query param &foo=President, for example, using a report name "urlparam" residing in your Public folder:
Attached is a js-export zip which can be imported. You'll need to ensure the datasource is correct and run as superuser.
Ref. Case #00029184
Recommended Comments