Skip to content

ReportParametersExtensions

mzuchowski edited this page Apr 2, 2015 · 1 revision

Introduction

Aperte Reports extends Jasper parameters standard, allowing to generate convenient interface for user input. Using Jasper parameter's properties, you can define type and behaviour of corresponding widgets displayed in application.

In this tutorial, we create a report design accepting role name and displaying usernames assigned to it. Role name will be selectable from the list of available roles in database.

Please note that parameters in iReport can be configured directly in XML view or with Properties window in in Designer view. For brevity, all examples are in the xml form.

All available parameters are described in ReportParameters.

Standard Jasper report design

As the base, we will use report design from SampleReportDesigns#Role_Users_-_Standard_version.

It contains:

  • role parameter
  • query for fetching users with role
  • title, column headers and text fields for displaying details

If you save it locally and open in iReport, you can run it and preview the results.

Datasource parameter

In order to run any report with SQL query on Aperte Reports, you have to additionally specify datasource parameter. The application will read parameter's description attribute as JNDI resource name of jdbc connection to execute this query.

Example:

<parameter name="parameter1" class="java.lang.String" isForPrompting="false">
<parameterDescription><![CDATA[java:comp/env/jdbc/liferay]]></parameterDescription>
</parameter>

User input parameters

If report contains also some parameters to be defined by user, you have to configure them to let Aperte Reports know, how to present them to user. In order to achieve desired result, mentioned in the introduction, we will extend role parameter with properties:

  • input type
  • dictionary query
  • required
  • required error
  • label

Input type

This property defines which Vaadin field type will be rendered on the user input form. List of avilable field types can be found in ReportParameters#input_type.

In this example we will use select type.

<property name="input_type" value="select"/>

Dictionary query

Property allowing to fetch from database values available in select box field. Value consists of JNDI datasource name and query, separated with semicolon: ";".

We use here the same datasource as main query. Please note that query have to return at least two columns.

<property name="dict_query" value="java:comp/env/jdbc/liferay; select name as key, name as value from role_"/>

Required

Makes Vaadin field required.

<property name="required" value="true"/>

Required error

Message shown to user, if required field is not filled in properly.

<property name="required_error" value="Select role name"/>

Label

Name of the field in form. If not set, parameter's name will be used as field name.

<property name="label" value="Role name"/>

Expected resuls

After parameters configuration, you should get the final design similiar to SampleReportDesigns#Role_Users_-_Extended_for_Aperte_Reports. If you upload it with Aperte Reports Manager, parameters form should look like this:

http://wiki.aperte-reports.googlecode.com/git/img/tutorial/role_users.png