LSPS documentation logo
LSPS Documentation
Jasper Reports Integration

The support for Jasper Reports is provided by the reports Module of the Standard Library: the Module contains the reports function definition with the following functions:

  • jasperReportUrl() returns the URL of a Jasper Report on a Jasper server
  • embeddedJasperReportUrl() returns the URL of the JasperReport in the LSPS Embedded Server

    Note: The LSPS Embedded Server integrates the Jasper Report library; hence no Jasper Server is called when working with the Embedded Server.

  • jasperReportPDF() generates the PDF version of the report with the provided parameters

Integrating Application User Interface with a JasperServer

To work with Jasper Reports on a Jasper Server, you need to obtain access to reports on an external Jasper Server. You can do so with the jasperReportURL().

Example URL of a Browser Frame component that points to a report on a remote Jasper server with no parameters

jasperReportUrl(
  "http://myremoteserverip:9090/jasperserver",
  "jasperadmin",
  "jasperadmin",
  "/reports/MyReports/myReport",
  false,
  ["topLimit"-> 120]
)

Important: Insert the full path to your report.

jasperReportPath.png
Path of the report in the web client

Enabling Expression Language in Jasper Reports

To enable data queries of Jasper Reports in Expression Language, do the following:

  1. Add lsps-runtime/jasperreports-extension/lsps-tools-jasperreports-extension-<VERSION>.jar to the classpath of your Jasper server (you can download its latest version with dependencies here).
  2. Set the property com.whitestein.lsps.datasource.url to point to base URL to the RESTful API

    For the Embedded Server, this would be set to http://localhost:8080/lsps-monitoring-ws/resources/report-ds/.

  3. Set the following parameters for your reports:
    • query language to LspsExpression
    • LSPS_MODULE_ID or LSPS_MODEL_INSTANCE_ID to define the context for the report data
    • authentication data as LSPS_USERNAME and LSPS_PASSWORD
  4. Define the data query in the Expression Language. Make sure the Expression returns a string with results in a valid JSON format.

Displaying a Jasper Report

You will typically display a Jasper report in a form using a Browser Frame or you will navigate away from the Document or To-Do to the report URL: On the Embedded Server, you can use the embeddedJasperReportUrl() which returns the URL of the JasperReport: The LSPS Embedded Server integrates the Jasper Report library; hence no Jasper Server is called.

To display your report in a Browser Frame, do the following:

  1. Add the report jrxml file to your GO-BPMN project.
  2. Open or create the Form definition.
  3. Insert a Browser Frame component into the Form.
  4. Define its URL property with the URL to the report using embeddedJasperReportUrl
    • on a Browser Frame as target Url embeddedJasperReportUrl(thisModel().name, "MyBamReport/HelloModel.jrxml", [ "editable"-> true])
    • on a Listener of a component, such as a Button: Forms.navigateToUrl((embeddedJasperReportUrl(thisModel().name, "MyBamReport/HelloModel.jrxml", [ "editable" -> true ])))

Mapping of Parameter Data Types

When you request a parametric Jasper report with one of the reports function of the Standard Library, on runtime, the data type of the parameter value is converted to its Java equivalent:

Expression Language TypeJava Type
String java.lang.String
Integer java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double
java.math.BigDecimal
Decimal java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double
java.math.BigDecimal
Boolean java.lang.Boolean
Date java.util.Date
List java.util.List
Set java.util.Set

Exporting a Jasper Report

To allow the user to export a Jasper Report into PDF, Excel, or Word and download it, call jasperReportExport() in a form component. The function returns a File with the report.

Example FileResource of a Download component with a PDF report

new FileResource(jasperReportExport(thisModel().name, "MyBamReport/HelloModel.jrxml", ReportFormat.pdf , [->]));

Example Click Listener of a Generate PDF button that generates the PDF report and sets the PDF Link component properties

{e ->
   def FileResource pdf :=
     new FileResource(
       jasperReportExport(
         thisModel().name,
         "MyBamReport/HelloModel.jrxml",
         ReportFormat.pdf,
         [->]
       )
     );
   PdfLinkComponent.setResource(pdf);
   PdfLink.Component.setEnabled(true);
}