Creating a Domain Report from iReport Tutorial
Introduction
This tutorial will enable you to use the powerful interface of iReport combined with the ease of use of domains to create complex layouts and calculations. This tutorial utilizes iReport to create reports based on Domains. Domains are a semantic layer that allows users to create reports without having to understand or write complex SQL. Additionally, end-users often use Domains to create Ad Hoc reports with the JasperServer Ad Hoc designer.
Objectives
This tutorial will enable you to:
Connecting iReport to Your Server
Create a connection to JasperServer from the Repository Navigator plug-in in iReport.
| Step | Action |
| 1 | Start iReport |
| 2 |
Verify that a connection to theJasperServer repository is defined and the domain plug-in activated:
The Repository Navigator window (red arrow) and the Domains Window (green arrow) will be visible, as indicated in the image below:
|
| 3 |
In the Repository Navigator window, click Add new server icon. Result: The JasperServer Plugin window appears:
|
| 4 |
A JasperServer Plugin window will appear. Enter the following:
Click Save
Result: Your server is added to list in the Repository Navigator section. Report developers can now interact with various resources that are contained in the JasperServer repository. |
| 5 | To verify that the connection was established properly, double-click your server’s name to load the repository. If the connection was created correctly, a hierarchical folder structure will appear. |
Setting Up Filters
Assumption: The demo samples that were provided with the installer have been deployed. The sample report is domain-report.jrxml; it uses the SupermartDomain sample.
| Step | Action |
| 1 | In iReport, go to File > New > Domain Report |
| 2 |
In the New wizard, select the server containing the Domain you wish to use, then click Next. Example: In the example, use SupermartDomain |
| 3 |
From the available groups of fields, double click to open the groups and display fields or subgroups within that group. Example: For this example, open the group and subgroups: Expenses > Stores > Regions
|
| 4 |
To create a condition, select the desired field and click Create Condition Example: For this example, select Country
|
| 5 |
The Condition Editor proposes operators based on field type (Text, Dates, …) Example: For this example, select Equals |
| 6 |
To complete the condition definition, click the (…) icon
Result: A popup window appears to prompt you for the available values. Select a value then click OK. Example: For this example select USA
Best Practice: Select multiple values using the control key. The ability to select multiple values will be driven by the selected operator. Example: is one of … |
| 7 |
The condition is defined and added to the query. The condition can also be used to prompt the user. If this is approach is taken, the condition is treated as a parameter.
From now you can add new conditions (repeat from step 4) or update an existing one (simply click on the condition listed, change settings then click add/update button). |
| 8 |
Note: Once you have selected a field within a given ‘data island’, fields that are part of another ‘data island’ will be greyed out. Click Next when prompted, enter a name and location for the report, then click Finish. |
Using Domain Fields
The filters are now set up. The next objective is to create a simple report using three bands (title, detail and summary). Additionally, the report will contain a variable.
| Step | Action |
| 1 |
Notice that the fields are listed in the Domain window but none of them are listed in the field list on the report inspector. The field node, within the Report Inspector window, will be populated with fields used by the report.
|
| 2 |
You can add a field to the report by dragging and dropping a field from the Domain window to the desired location in the report. Example: For this example, drag the field “Country” to the top left of the title bland. Notice the fields list in the report inspector now contains the Country field.
Repeat the previous steps with the following fields listed below.
|
| 3 |
Create a variable that counts the stores in a country. Prior to defining the variable, we have to add store_name field to the report. There are two ways for adding a field to a report.
Example: For our example, right-click on Store_name and select Add field to report |
| 4 |
Example: For our example, create a variable store_count and then assign the values below: For the variable expression select the field $F{expense_fact.exp_store.exp_store__store_name}
|
Publishing the Result and Testing It
Now we have a report, let’s publish it and test it. One of the advantages of using domains is that the report development process is simplified; There is no data source to set up and no input controls to manage.
| Step | Action |
| 1 | On the domain window click the Publish button |
| 2 | In the wizard, provide a name for the report (no special characters and no spaces) and a label. |
| 3 |
Select a folder for storing the report (in our sample the public folder).
|
| 4 |
Click Finish Result: The report has been published to JasperServer repository. |
| 5 |
Test the report within iReport Go on the repository navigator then open the folder containing the report. Right-click on the report unit and select “Run Report Unit”.
The report is being executed and filled by the server and the result will be displayed in iReport. |
Additional Information
|
What's Next?
You can view a completed sample of this here.
Written By
This tutorial was written by Guillaume Autier, Sales Engineer, June 2009
Language















