In the previous article, we updated an existing report on a Jasper Server.
This time, we'll look at how to define user-entered parameters for a report.
To define a set of parameters for a report, you can add parameters using the Report Inspector:
You can define the default values for a report. Once you’ve defined a parameter, you can reuse this elsewhere, for example in the SQL for a report:
You reference the parameters using $P{name}, in this case $P{table_schema}.
Using this, you can filter the output of a report. But to use them, you need to specify how the user enters them. The entry of values isn’t done in the report, but in the Report Unit. You need to define Report Unit Input Controls.
You can define an Input Control so that the user can specify a parameter for a report. For the report defined previously, you could specify a value for the table_schema.
In the Report Unit, create an Input Control:
Enter the Name and Label :
The label will be visible to the user. You need to define the details in the tab Input Control Details. For a list of items from the database, use Single Select Query. You can mark the value as mandatory as well here.
To define the SQL statement, click on the Edit Local Resource button:
You'll need to enter a name and label for the local resource (table_schema/table_schema), and then click on the Query tab to define the SQL:
If you select a data source of 'None', the data source used will be that defined for the Report Unit. In the tab Value and Visible Columns, you need to define the value which will be passed to the report, and the columns visible which will be displayed to the user:
After deploying to the server, when you run the report the web site will display a input page.
And the report displays the information for the table schema chosen.
Next we'll look at how to modify the user rights for the reports and other objects on Jasper Server. Next>>
1 comment:
Hi there!
Just wanted to say thank you so much for this plain explanation. I've spend literally hours trying to figure out how the input controls are linked to parameters but everybody seems to take thins knowledge for granted :/
So thanks a lot again!
Post a Comment