JRXML-based reports can include input controls that have dynamic values. The values depend on a user's selection in other input controls. For example, a report has input controls for country, state, and city. The options in the State input control depend on the value selected in the Country input control. When the user selects a state, the list of values includes only those in the selected state. These cascading input controls use queries to determine the values to display in each input control field.
To use input controls as parameters for a query that populates another input control, you use a special syntax to reference a parameter name in the input control's query. The syntax is identical to the $P{parameterName} syntax used in queries for JasperReports. For more information about defining the input control’s query, see section Adding a Query-Based Input Control.
For example, a report returns data identified by country and city. It includes input controls called COUNTRY and CITY. This query used by the CITY input control retrieves city names from a table called accounts based on the value selected by the COUNTRY input control:
select city from accounts where country = $P{COUNTRY} |
When the user selects a country from the COUNTRY input control, the value selected is used by the query of the CITY input control; the CITY input control is refreshed to show the result. Note that there are other ways to use a parameter in a query.
For an example of a report that has cascading input controls, see section Cascading Input Controls.