Jump to content
Changes to the Jaspersoft community edition download ×

  • djohnson53
    • Features: Ad Hoc, Domains, JasperReports Server Version: v5.1 Product: JasperReports® Server

    Introduction

    This tutorial will enable you to use the powerful interface of iReport Designer combined with the ease of use of domains to create complex layouts and calculations. This tutorial utilizes iReport Designer 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 JasperReports Server Ad Hoc designer.

    Objectives

    This tutorial will enable you to:

    Connecting iReport Designer to Your Server

    Create a connection to JasperReports Server from the Repository Navigator plug-in in iReport Designer.

    Step Action
    1 Start iReport Designer
    2

    Verify that a connection to the JasperReports Server repository is defined and the domain plug-in activated:

    • Go to Window > JasperReports Server repository
    • Go to Window > Domains

    The Repository Navigator window (red arrow) and the Domains Window (green arrow) will be visible, as indicated in the image below:

    JEM_DomainReports_1.png.a62a48b293cb82cfd515b9e74710f8c5.png

    3

    In the Repository Navigator window, click Add new server icon.

    Result: The JasperReports Server Plugin window appears:

    JEM_DomainReports_2.png.00cf8f63b23415ea33e837120af50dd7.png

    4

    A JasperReports Server Plugin window will appear. Enter the following:

    • Name: Name of your server
    • JasperSrver URL: Specify the url of your server repository: Http://[ip-adress]:[port]/jasperserver-pro/services/repository
    • Organization: Enter the organization_id
    • Username: Enter the username
    • Password: Enter the password.

    JEM_DomainReports_3.png.ab5385dc562f8d1db2bea88d5c459aa9.png

    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 JasperReports Server 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 Designer, 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

    JEM_DomainReports_4.png.bb7e2950aefd0a8e292b8284a8a51bf9.png

    4

    To create a condition, select the desired field and click Create Condition

    Example: For this example, select Country

    JEM_DomainReports_5.png.db9a6ba7ce4b30a86d7de5cd4ba95075.png

    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

    JEM_DomainReports_6.png.553f0b25ff8a47d97ccd8ab767dc403f.png

    Result: A popup window appears to prompt you for the available values.

    Select a value then click OK.

    Example: For this example select USA

    JEM_DomainReports_7.png.71dc188d5674ebe4636bfc9d4298ed68.png

    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.

    • Example: Prompt the user to select a different country.
    • Check the is for prompt box
    • Click add/update condition button.
    • The condition is now listed. Note the (for prompt) indicates that a parameter and a input control have been created for this condition.

    JEM_DomainReports_8.png.421c4a96287b6f10fc79cb6e3c673f0c.png

    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.

    JEM_DomainReports_9.png.4002438f12e9ff27227d137ba529da7f.png

    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.

    JEM_DomainReports_10.png.d326bcd6cbd1ad60916d1379746a1824.png

    Repeat the previous steps with the following fields listed below.
    Drag each field into the detail band:

    • City
    • Expense Date
    • Expense Amount
    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.

    • Drag-and-drop, OR
    • Right-click on the field name in the Domain window and then select Add field to 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}

    JEM_DomainReports_11.png.0cb21e8a40f0072a71da489da1e8b692.png

    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).

    JEM_DomainReports_12.png.0af4e7c390b833afc2f5e70d858cc1ab.png

    4

    Click Finish

    Result: The report has been published to JasperReports Server repository.

    5

    Test the report within iReport Designer

    Go on the repository navigator then open the folder containing the report. Right-click on the report unit and select “Run Report Unit”.

    JEM_DomainReports_13.png.ea2fa83c47f733430055047ebfc684b0.png

    The report is being executed and filled by the server and the result will be displayed in iReport Designer.

    Additional Information

    • You can edit the filters anytime by clicking the Edit Filter button in the Domain Windows
    • You can see the Domain query using the report query icon; this will display the semantic layer query.
      • You can modify it here if you wish:
      • JEM_DomainReports_14.png.0bc7537f9d4a8d4e1e9b8492f14010c1.png
    • iReport Designer cannot use Domains alone; reports have to be published on the server as only JasperReports Server understands Domain queries
      • Which is why some automated features of iReport Designer cannot work
    • Create conditions between two fields:
      • In the Condition Editor, select two fields by holding the control key
      • Click Create Condition
      • You can switch the field position; use the swap button on the right side
      • JEM_DomainReports_15.png.ba5c6e51c307c125bf37f30c94516a4f.png

    What's Next?

    You can view a completed sample of this jem_domain-report_sample.jrxml

    Written By

    This tutorial was written by Guillaume Autier, Sales Engineer, June 2009

    JEM_DomainReports_14.png.00088eb722d69bc6e7b03e371e46639a.png

    JEM_DomainReports_15.png.4e846ce7004edad816c8bd8870b7e277.png

    jem_domain-report_sample.jrxml


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...