Testing Reports with JasperReports IO

Jaspersoft Studio comes with a built-in JasperReports IO reporting engine. When you preview a report with JasperReports IO, Jaspersoft Studio starts an instance of a web application server running JasperReports IO on the local machine.

This section assumes that you have already set up a JasperReports IO repository under your workspace.

Importing JasperReports IO Resources into Your Project

To import resources from the JasperReports IO file system:

1. Start Jaspersoft Studio.
2. Open the Project Explorer and select your project.
3. Select File > Import.
4. Select File System from the General category.
5. Click Next.

The import wizard opens.

6. Use the Browse button for From directory to navigate to the top-level directory of the JasperReports IO repository.
7. Select the directory and click OK.
8. Check the folder's checkbox in the left panel.
9. Use the Browse button for Into directory to navigate to the workspace folder into which you're importing the repository.
10. Select the workspace folder and click OK.
11. Select how Jaspersoft Studio will import the repository's resources into your workspace using the following options:
a. Overwrite existing resources without warning - Select this option to replace existing resources in the workspace with newer versions without any warning prompts.
b. Create top-level folder - Select this option if you want the selected top-level directory of the repository to be recreated as part of the project. If you do not select this option, Jaspersoft Studio will import the contents of the selected directory directly into the project folder.

The options under Advanced allow you to create links to files located outside of your workspace. However, the built-in JasperReports IO preview engine only works for files located in your workspace. It is not available for previewing linked files located outside your workspace.

12. Click Finish.

The repository and its resources are imported into your project and appear in the Project Explorer.

Configuring Jaspersoft Studio for JasperReports IO

Previewing reports using Jaspersoft Studio's JasperReports IO reporting engine requires you to first configure the following:

The project's repository type
The repository's root folder
The starting port for the JasperReports IO web application server

Changing the Project's Repository Type

When working with report templates for JasperReports IO, you will need to switch your project's repository type to JasperReports IO to preview your reports using the JasperReports IO reporting engine.

To change the repository type, right-click the root folder for your report templates in the Project Explorer. This can be the project root folder or another folder in the project. Then select Report Repository Type > JasperReports IO. Jaspersoft Studio can now preview these reports with the JasperReports IO web application server.

You can change the repository type of any folder in your workspace to one of the following: JasperReports IO, JasperReports Library, or JasperReports Server. This allows you to design and test your reports in different environments.

Setting a Project Folder as the Repository Folder

By default, your project's root directory is the root directory for your JasperReports IO repository, which allows reports to use all the resources in your project. You can limit the resources that your reports can use by specifying a new repository root folder. You can specify multiple repository root folders for your JasperReports IO resources and the order in which your reports will look in them.

To set a repository folder:

1. Select your project in the Project Explorer.
2. Select Project > Properties to open the Properties window for the project.
3. Expand the Jaspersoft Studio node.
4. Select the JasperReports IO Repository node.
5. Click New.
6. Select the folder you want to use as the repository root directory.
7. Click OK.
8. Repeat steps 5 though 8 for each folder you want to use.
9. If you have multiple repository root folders, you can use the Up and Down buttons to move them into the order in which your JasperReports IO web application server will look for its resources.
10. Click Apply.

Setting the Starting Port for the JasperReports IO Preview

Jaspersoft Studio starts a web application server the first time you preview any report with JasperReports IO. By default, the JasperReports IO web application server runs on port 8080. If that port is already in use, either by another application or another JasperReports IO instance, the web application server will attempt to use port 8081 and will continue to try the next port until it finds one that is not in use. You can specify a different port for JasperReports IO to use when it starts by setting a new starting port.

Jaspersoft Studio keeps the web application server running until you delete the project or close Jaspersoft Studio.

If you have multiple JasperReports IO projects in Jaspersoft Studio, each one uses its own web application server. You can have multiple JasperReports IO instances running on different ports at the same time until you delete a project or close Jaspersoft Studio.

To set the starting port:

1. Select Window > Preferences to open the Preferences window (Eclipse > Preferences on Mac).
2. Expand the Jaspersoft Studio node.
3. Select the JasperReports IO node.
4. Enter a new starting port for the Port Range Start Number.
5. Click Apply.

Jaspersoft Studio starts a web application server for the first time when you preview a report with JasperReports IO. One server per project uses a free default port 58080. In case you want to change the port range, you can do it from the preference page and restart studio.

Previewing a Report in JasperReports IO

When you select the Preview tab at the bottom of your report, Jaspersoft Studio starts a web application server running a JasperReports IO instance. The Jaspersoft Studio compiles the report using the data retrieved by the query through the selected data source and the resources in your JasperReports IO repository. If the compilation runs successfully, the produced report is loaded by JasperReports IO and filled using the data source.

Note that Jaspersoft Studio automatically saves the report without prompting you.

You can change the data source to use with the report and enter any input. You will be prompted to save the report template when you change the data source. If you click Save, Jaspersoft Studio will save the report template with a new parameter that specifies the data source type and path.

If you change the data source or enter any new input parameters, click the button to run the report.

Exporting the JasperReports IO Templates and Resources

When the report templates are ready for JasperReports IO, you can export the templates and resources to an external folder to later be used by JasperReports IO.

To export the JasperReports IO templates and resources to an external folder:

1. Select the repository folder in the Project Explorer.
2. Select File > Export.
3. Select File System from the General category.
4. Click Next.

The export wizard opens. The selected folder appears in the left panel. The folder's checkbox is checked along with all of the sub-folders. Clear the checkbox for any folder or file you don't want to export.

5. Use the Browse button for To directory to navigate to the destination directory.
6. Select the destination directory and click OK.
7. Select how Jaspersoft Studio will export the JasperReports IO resources to the destination directory using the following options.
a. Overwrite existing resources without warning - Select this option to replace existing resources in the destination directory with newer versions without any warning prompts.
b. Create directory structure for files - Select this option to create a directory structure in the destination directory based on the full folder structure of the repository as seen in the Project Explorer.
c. Create only selected directories - Select this option to create a directory structure in the destination directory based only on the folders selected in the export wizard.
d. Resolve and export linked resources - Select this option to export copies of selected linked resources to the destination directory.
8. Click Finish.

The files are exported to the destination directory.

Exporting the HighCharts-based report with the JasperReports IO plugin can be done by using Chrome/Chromium. The application auto-detects the Chrome/Chromium in the eight predefined locations.
If the application does not find Chrome/Chromium in these predefined locations, then point the application to the location of the Chrome/Chromium by specifying the path to the chrome executable in net.sf.jasperreports.chrome.executable.path property in the following file:
[JSS_INSTALL]/jrio/jrio/WEB-INF/classes/jasperreports.properties