RENATO ALMEIDA DE OLIVEIRA

Playing with JasperReports - Part 1 Input Controls

Blog Post created by RENATO ALMEIDA DE OLIVEIRA on Jun 26, 2017

   Hello folks, This is mine first draft about Jasper Reports and at the end of the series you will be able to create a full customizable report.

 

What is an Input Control:

 

   According the documentation an Input control are correspondent to the parameters in the report such as $P{name}, and is defined as :

Input controls are graphical widgets the server displays with the report. Input controls perform the following functions:

Prompt the user for input
Validate the format of the input
Pass the input to the report

Based on the input, the server modifies the WHERE filter clauses in SQL parametrized queries

 

How to crate an Input Control:

 

1.      As superuser goto the repository

2.      As a good practice I recommend to create a folder on the public folder named InputControls and store yours input control there, to do that right click the Public folder and Create folder

Create a folder

3.      Expand the public folder and right click on the recent created folder input control, Add Resource -> Input Control

Create Input control

4.      Chose the parameter type, in this tutorial I gonna use the Single-Select Query that is a very interesting kind wich performs a query before asks the input allowing the user to chose based on that query

5.      Fill the fields, in this tutorial I gonna create an Input Control that querys all the global collections with the Group A security string that is groupA

6.      Click Next, In this step is possible to select an already  existing query but in this tutorial i gonna create one so click next again

7.      Give a name to the query and click next

8.      Select "Select data source from repository "  and chose spectrum_ds data source, and click Next

9.      Here I use the following query that make a join with the globalcollection and the models table filtering by the security string

SELECT distinct reporting.globalcollection.gc_name GC
FROM reporting.globalcollection
     INNER JOIN reporting.model ON
     reporting.model.model_name = reporting.globalcollection.gc_name
WHERE      reporting.model.security_string LIKE '%groupA%'

10.      Click Save

11.      In this screen you gonna select the wich column of your search are gonna be the parameter value (Value Column) and wich are gonna be visible for the user (Visible Column)

12.      Click submit and its done.

 

That's all for now, if there are any doubts or sugestions please leave a comment, and in the next tutorial I gonna teach how to create a report using this Input Control, and if there are any kind of report that you wish leave a comment too and maybe I use your suggestion to create the next tutorial.

Outcomes