Connecting to JasperServer from iReport
Using the JasperServer Plug-in for iReport
The JasperServer plug-in for iReport provides report developers with a quick and easy way to access reports inside the JasperServer repository. The plug-in uses the JasperServer web services to interact with the server, and you can connect to multiple servers. This can make it easy to access both test and production environments.
|
This section assumes that you installed iReport when you installed JasperServer. For more information, refer to section iReport Plug-ins. JasperServer supports the version of iReport that ships with it; you cannot necessarily use a version of iReport or JasperReports that has a later version number than the version of JasperServer you use. Jaspersoft keeps the release numbers of compatible versions consistent. For example, Jasper Server 3.7 supports iReport 3.7 and JasperReports 3.7. |
The plug-in offers these features:
• Repository browsing.
• Create, modify, and delete folders, generic resources (including images, fonts, JRXML files, JAR files, and property files), reports, datatypes, list of values, and input controls.
• Create, modify, and import data sources (JDBC, JNDI, and JavaBean).
• Add, remove, and link controls to reports.
• Drag and drop images and sub-reports into the design page.
• Access to Domains through the Domains plug-in for iReport.
This section includes these topics:
• Connecting to JasperServer from iReport
• Creating a Report Unit in the Repository from iReport
• Managing Resources in the Repository from iReport
• Editing a Report in the Repository from iReport
• Running a Report from iReport
• Creating Reports in iReport Based on a Domain in JasperServer
• Creating Chart Themes in iReport
Connecting to JasperServer from iReport
You can connect to JasperServer (Professional or Enterprise) directly from iReport.
To access the JasperServer repository within iReport:
1. | Start iReport. For example, in Windows select Start Programs JasperServer Pro Start iReport on the computer hosting JasperServer. |
iReport appears.
2. | Open the JasperServer Plug-in for iReport by clicking Window JasperServer Repository. |
The Repository Navigator tool bar appears:
3. | When iReport starts for the first time, no servers are configured. To add a server, click the first button in the repository navigator tool bar. |
|
Connecting to JasperServer from iReport |
4. | Enter the information that the plug-in will use to access your JasperServer instance. All fields are required: |
• Name – An identifier for this JasperServer instance and its repository in the iReport Repository Navigator.
• JasperServer URL – Full URL to the repository web service; the default URL is provided and you only need to change the hostname.
• Organization – If there is more than one organization in the JasperServer instance, you must specify the ID or the alias of the user’s organization, for example organization_1. In the default installation with a single organization, you can leave this field blank.
• Username – ID of the user account to use when accessing JasperServer. The view of the repository and any actions you take through iReport will use the permissions for this user.
• Password – Password for the given user.
5. | Click Save, then expand the repository tree in the Repository Navigator. The JasperServer repository tree appears as it would to the user in the given organization. |
You can add any number of servers to this list. If you have multiple versions of the plug-in installed, the list includes all the servers configured for every version iReport (after 3.1) that is installed on this computer. Note that you may experience problems when connecting to servers that are not compatible with your version of the plug-in.
|
iReport Displaying a Report from the Repository Navigator |
6. | For each server to which you have configured access in the JasperServer Plug-in, you can: |
• Browse the repository by double-clicking the server and folder icons.
• View the property information of the resources in the repository.
• Download, edit, and upload JRXML files.
• Download images and other files by clicking Export File on the Resources tab of the resource’s Properties window.
Creating a Report Unit in the Repository from iReport
To add a new report unit, you need a JRXML file, which you should create in iReport beforehand. A report has a main JRXML file, a data source, a set of input controls (zero or more), and a set of resources (zero or more). To create a report that returns data from a Domain, see section Creating Reports in iReport Based on a Domain in JasperServer.
To create a report unit in the repository:
1. | Right-click the parent folder for the new report and click Add Report Unit in the context menu. |
You are prompted for the main JRXML file.
2. | Select a JRXML file in the repository or one saved on your hard drive. If you have a report open in the design area, select Locally Defined and click Get source from current opened reportto use it in the new report unit. |
3. | Click Next. |
You are prompted for the data source.
4. | Select a valid data source (either from the repository or locally defined) and click Finish. |
5. | The report unit appears in the repository tree. If it doesn’t, right-click the server name and select Refresh from the context menu. |
6. | To add an image from the repository to a report, drag the image into the design window from the repository tree. |
The iReport plug-in adds the image element for you, setting an expression that refers to the image’s location in the repository.
7. | To add a subreport to a report, drag the JRXML for the subreport from the repository into the detail band. The JRXML for the subreport must already be created and saved as a resource in the repository or in the report |
A sub-report element is created. If the main report uses a JDBC connection, set the connection expression of the sub-report to $P{REPORT_CONNECTION} in the Properties window’s subreport tab.
|
You cannot run a subreport directly on the server; you must run the whole report unit. |
8. | To run the report, right-click the report unit and select run Report Unit from the context menu. For more information, refer to Running a Report from iReport. |
|
When you upload a report that uses the repo: syntax to refer to resources in the repository, iReport prompts you to locate the resources. Browse the repository to the correct resource and click OK. |
Managing Resources in the Repository from iReport
While creating reports that you intend to store in the JasperServer Repository, you will also need to create and manage the resources associated with them, such as images, JARs, JRXML files, properties files for localized reports, input controls, datatypes, lists of values, style templates (JRTX), and data sources. Or if you are maintaining existing reports, you may need to access, modify, and save changes to existing resources. You can also modify the location, name, or description of the repository folders.
To add, modify, or delete resources to the repository from iReport:
1. | To add a resources in the repository navigator, right-click the folder that will hold the resource, select Add then click the desired object in the context menu. |
2. | To change the location of a resource in the repository, locate the object, then drag-and-drop it to the new location. |
Alternatively, right-click the object and select Copy or Cut, or use the keyboard shortcuts: Ctrl-C and Ctrl-X, respectively. Locate the destination and right-click and select Paste, or use the keyboard shortcut Control-V. When cutting the object, it will not be removed from its original location until pasted in the new location.
3. | To delete a resource from the repository, locate the object, right-click it, and select Delete. You must confirm you action to prevent accidental deletions. |
4. | To modify a resource, navigate the repository tree to find its folder, then right-click the resource and select Properties. |
5. | In the dialog window that appear, there are one or more tabs depending on the type of resource. On the General tab, you can view the object’s repository label and description. If the logged in user has administrative privileges, you can modify the values and save them back to the Repository. |
|
Editing General Properties of Repository Objects in iReport |
The other tabs, if any, contain controls that are specific to each type of resource. File-based resources have a Resource tab to replace or export the file, and other repository objects have their own specific settings. As shown in the following figure, an image resource shows the image itself, and an input control lets you edit its various parameters:
|
Editing Resource-Specific Properties of Repository Objects in iReport |
6. | Click Save in the Properties dialog to make your changes effective in the repository. |
Editing a Report in the Repository from iReport
In the repository tree, report units appear as special folders with this icon: . They contain JRXML files with this icon:
. When working with JRXML files in the Repository from iReport, you must be aware that iReport operates on a copy of the file. You must upload it back to the repository when finished, as explained in the following procedure:
To edit a JRXML file in the Repository from iReport:
1. | In the repository tree, right-click the JRXML file in the report unit and select Open in Editor. |
The JRXML is extracted from the repository and stored as a local copy in the <USER_HOME>/.ireport/jstmp directory. This directory is never automatically cleared out.
The JRXML appears in the Designer window.
2. | Edit the file as needed, either in the Designer or in the XML editor. See section Creating a Report Unit in the Repository from iReport for instructions on adding images or subreports to your JRXML file. |
3. | To save the file and upload it to the repository, right-click it in the repository tree and click Replace with Current JRXML. |
A message confirms the operation’s success.
To edit a Report Unit in the Repository from iReport:
1. | In the repository tree, right-click the report unit and select Properties. |
2. | On the General tab, change the repository name or description as appropriate. |
3. | On the Main Report and Data Source tab, you can change the JRXML file for the report, either by selecting one from the repository, or uploading one through iReport. Click Current Report to use the JRXML currently being edited in iReport. Similarly, you can select the data source from the repository or from iReport. See Editing Parameters of a Report Unit in iReport. |
4. | On the Other tab, you can set display properties for any input controls. The JSP fields are for modifying the appearance of the controls, and the Controls Layout determine where they appear. |
|
5. | Click Save Report Unit in the Properties window to make the changes effective in the JasperServer repository. |
Running a Report from iReport
To run a report on the server using all the export options set in iReport:
1. | Right-click a report in the repository tree and click Run Report Unit. |
2. | If the report has input controls, the Report Parameters window prompts you for values. |
|
Report Parameters Window in iReport |
The report is displayed in the Report Viewer Window. If the report does not display, look for errors or messages in the Report Problems Window at the bottom of the iReport interface.
Creating Reports in iReport Based on a Domain in JasperServer
A Domain is a virtual view of a data source that represents the data in business terms appropriate to your audience, and it limits the data to that which is appropriate for the audience. For more information about Domains, see chapter Creating Domains.
The Domain plug-in enables iReport users to generate reports from Domains. The plug-in is installed in iReport by default. It relies on the JasperServer plug-in to access the repository.
To create a report in iReport based on a Domain in JasperServer:
1. | Configure iReport to access your JasperServer repository as described in section Connecting to JasperServer from iReport. |
2. | Click Window Domains. |
The Domain Window appears docked on the left-hand side of the screen.
|
Domains Window in iReport |
3. | To start a report based on a Domain, click File New Domain Report. |
The Domain Report wizard opens to the Connection step:
|
Connection Step in the iReport Domain Report Wizard |
4. | Select a JasperServer connection to determine the server and repository containing the Domain you want, then click Next. |
|
Domain Step in the iReport Domain Report Wizard |
The Domain step displays a selector containing all the Domains within the repository visible to the user defined in the connection. If the user’s organization includes sub-organization, the list will include any Domains they define as well.
5. | Select a Domain and click Next. |
|
Filters Step in the iReport Domain Report Wizard |
The Filters step displays the Domain’s items, which may correspond to fields and calculated fields in the Domain.
6. | Define any necessary filter conditions on the fields of the Domain. Even if that field is not included in the report, the filter will be active and will apply to the rows of data that will appear. |
Filters will limit the data your report will return, and you may select any field to prompt the user with an input control. This dialog is similar to the Filters page in the Choose Ad Hoc Data wizard within JasperServer. For more information, see section The Filters Page.
7. | Click Next and specify a name and a location on your hard drive to save the report. |
|
Name and Location Step in the iReport Domain Report Wizard |
The Name and Location step determines the file name of your report in iReport, not in the JasperServer Repository. See below to publish your report in the repository.
8. | Click Finish. |
The report document appears in design area. The Domain Window now shows the sets and items in the Domain.
9. | To add items from the Domain, drag them to the detail area of the JRXML in the designer. Edit your report to format its data and look and feel. |
|
Designing a Report in iReport Based on a Domain in JasperServer |
If you want to change the filters on the Domain data, click Edit Filters in the Domains Window. Filters are defined as queryFilterString elements in the XML of the report. Click XML next to Designer to view the XML. For the simple filter shown in step 6., the generated XML is the following:
<queryField id=”newSet2.amount”/> <queryFilterString>newSet2.amount >= 10000</queryFilterString> |
The query has two elements: queryFields and queryFilterString:
• Field IDs in both elements are specified as set_ID.field_ID.
• The filter uses the Domain Expression Language described in section The DomEL Syntax.
10. | When you are satisfied with the report, save your report, then click Publish Report in the Domain window. |
You are prompted for a name, label, and description of the new report unit.
11. | Enter a name (object ID), label (display name) and an optional description for the report in the repository, then click Next. |
You are prompted for location for the report unit.
12. | Select a valid repository location and click Finish. |
13. | If the report doesn’t appear in the repository tree, right-click the server name and click Refresh. |
14. | With the report published to the server, you can test it by clicking ![]() |
The report output appears in the Report Viewer Window.
|
You cannot run a Domain report until it has been published to JasperServer. |
Creating Chart Themes in iReport
Using iReport, you can create new chart themes that give a custom look to any chart. You can easily set the fonts, colors, line widths, and other settings that determine the appearance of charts. You can then import the chart theme for use in reports generated in JasperServer, either on a report-by-report basis or as a global setting for all charts that do not provide their own theme.
To create a new chart theme in iReport:
1. | Select File New Chart Theme. |
The new file dialog opens with a default file name. Chart themes use the .jrctx file extension.
|
New Chart Theme in iReport |
2. | Enter a name and location and click Finish. |
Alternately, open an existing chart theme file with the .jrctx extension.
The chart theme editor appears in the Designer window.
3. | Use the following panes to work with your chart theme: |
• Template inspector on the left . Contains the categories of properties that can be modified.
• Chart properties on the right. Lists the properties in each category and lets you modify their settings.
These panes are shown in Chart Theme Editor in iReport.
The available options are based on the JFreeChart library used to generate charts. Note that iReport only supports the most common options provided by JFreeCharts.
4. | Select each category in the template inspector and review the available option, which appear in the properties pane to the right. |
5. | Select a property to change its value. Depending on the nature of the property, you might type text, select a color, check or clear a check box, or select a value from a dropdown. |
As you update the chart theme, the Designer shows your changes. For example, change the Series Color property in the Plot category to set the color of the data series in the chart.
Selector different chart types from the dropdown at above the Designer to see how the theme appears with different types of charts. This is especially important if you are creating a theme that will be used with many reports, such as a corporate chart theme.
To view the XML that defines the chart theme’s appearance, click XML above the Designer.
|
6. | When you are satisfied with the chart theme, click File Save to save your chart theme. |
This saves the report to your local hard drive.
7. | In the template inspector, right-click Chart Theme and click Export as Jar from the context menu. |
|
Exporting a Chart Theme |
You are prompted to identify the chart theme.
8. | Enter the name of the theme and the name of the JAR file. |
The chart theme name is the text that appears in the Chart Theme dropdown in iReport’s properties pane.
9. | If you don’t want this theme to be available in iReport for some reason, clear the check box. |
10. | Leave the box checked if you want the JAR to be placed on iReport’s classpath. |
11. | Click Export. |
The chart theme is exported. It can be used at the report or server level in JasperServer. For more information, refer to the JasperServer Administrator Guide.
|
In iReport, you can upload the chart theme to JasperServer using the JasperServer plug-in; right-click the folder in the repository where the theme should reside, and select AddJAR Archive. |