Report (element)

From JRapid

Jump to: navigation, search

JRapid provides integration with reporting tools. It allows developers to easily include reports created using Jasper Reports. Reports can be fully parameterized through JRapid's generated UI.

This feature is much stronger when developing SaaS applications because it allows managing a model where reports are deployed for each tenant. JasperReports is an open source Java reporting tool that can write to screen, to a printer or into PDF, HTML, Microsoft Excel, RTF, ODT, Comma-separated values and XML files. It can handle scriptlets in the report definition, subreports, and multiple datasources merging.

See JasperReport Home Page.

Contents

iReports

caption

iReports, a Graphical report designer for JasperReports is available from Jasper Forge too. This is the easiest and fastest way to create reports, and obtain the compiled .jasper file that has to be included in your JRapid project.

See iReport Home Page.

Integration modes

Reports can be integrated in two main different ways: as application reports or dynamically deploying them in the repository. When developing multi-tenant SaaS applications (a single instance of software serving multiple client organizations –tenants-) it becomes necessary to identify the features that are common to all tenants from those that are specific for each one, and different integration models appear for each one of these cases.

See Location (attribute of report) for more information.

Creating a Report

No matter which mode is used, the first thing to do is create a report definition in your JRapid project. This is done through the New Report option in the New menu.

This brings up the Edit report dialog.

A unique name for the report must be entered. Depending on the location chosen the file field must be completed with different considerations that will be discussed in the following sections. After clicking the Ok button the report will be shown in the entity diagram.

Previewing a Report

Once the report is created in the JRapid project, the .jasper file is uploaded to the server and a full generation is done, it can be accessed through the URL

http://SERVER_NAME.jrapid.com/APP_NAME/report/REPORT_NAME

where REPORT_NAME is the name given to the report in the JRapid project, not the .jasper file name.

Displaying Reports

Reports can be opened through an action placed in a listing or form. A new action of type "report" must be defined for that entity.

This generates the necessary code for the report to be opened in a new browser window when the button of the action is clicked. It also takes the id of the currently selected record on the list or opened record in a form and passes it as a parameter to the instantiated report. If the report depends on this parameter and wants to make use of it, it must define an input parameter of type string named “id”.

Other default parameters

When a JasperReport is opened from within a JRapid application it automatically receives some default parameters. This must be defined in the JasperReport if they are to be used.

- REPOSITORY: location of the file repository.

- SUBREPORT_DIR: location where the reports are contained in the application.

When a report includes a subreport, it's location must be specified relative to one of this two locations, depending on whether it is an application or a repository type report. A default value for this parameters is passed but it does not include the finalizing file separator, so when indicating the subreport expression one must use:

$P{SUBREPORT_DIR} + System.getProperty(“file.separator”) + "SubreportFile.jasper"

Different outputs

JasperReports can be rendered into PDF, HTML and xls using the same .jasper file from a JRapid application.

Important

As mentioned before, JasperReports can handle scriptlets in the report definition. This scriptlets can be written either in Java or Groovy language, and this can be configured as a report property. JRapid applications only support reports created with Java as the scriptlet language.

Jasper Reports may include images and the developer must be careful when specifying the image file location. The report will fail to be shown if it cannot find the image. To avoid this, be sure to set the “On error type” property for the image to a value different than the default “Error” one.

See also

Personal tools