As you all know, Servoy combines the best of all standard and open projects. So first we made a report engine within Servoy. For more complex reports we have chosen JasperReports to make reports and include them in your Servoy solution.

JasperReports is a powerful open source Java reporting tool that has the ability to deliver rich content onto the screen, to the printer or into PDF, HTML, XLS, CSV and XML files. Generating reports is a common, if not always glamorous, task for programmers. In the past, report generation has largely been the domain of large commercial products such as Crystal Reports. Today, the JasperReports report generating library gives Servoy developers a viable tool to make reports. Its main purpose is to help creating page oriented, ready to print documents in a simple and flexible manner. JasperReports provides the necessary features to generate dynamic reports, including data retrieval using JDBC (in this case supported by Servoy), as well as support for parameters, expressions, variables, and groups. JasperReports also includes advanced features, such as custom data sources, scriptlets, and subreports. All in all, JasperReports combines good features, maturity, and community participation. JasperReport is only an engine! Its works with special XML files. You can make these files by hand, but nobody is doing that, so you need a report designer

iReport is a powerful, intuitive and easy to use visual report builder/designer for JasperReports written in 100% pure java. This tool allows users to visually edit complex reports with charts, images, and subreports. iReport is integrated with leading open source chart libraries for java.

Getting started
First you need the Servoy Jasper Report plugin. In this plugin you will find the necessary files to combine Servoy with the Jasperreport engine. This will give you the possibility to make a call to the servoy-side of the plugin and retrieve the result in different kinds of output. Unzip the Jasper Reports Plugin zip file. Content:
plugins\jasperPluginRMI.jar plugins\jasperPluginRMI.jar.jnlp plugins\jasperPluginRMI\commons-beanutils.jar plugins\jasperPluginRMI\commons-collections.jar plugins\jasperPluginRMI\commons-digester.jar plugins\jasperPluginRMI\commons-javaflow.jar plugins\jasperPluginRMI\commons-logging-adapters.jar plugins\jasperPluginRMI\commons-logging-api.jar plugins\jasperPluginRMI\commons-logging.jar plugins\jasperPluginRMI\itext.jar plugins\jasperPluginRMI\jasperreports.jar plugins\jasperPluginRMI\jdt-compiler.jar

First you stop Servoy developer or server and extract the contents of this zip file in your Servoy directorie and let the subdirectories of the zip file intact. Start Servoy developer and choose the preference panel from the menu. You will see a new tab panel “JasperReports”. Type the directory where you wise to store your reports. Now you ready to integrate JasperReports in your solution. Alternatively you need a report designer to make your reports. In this tutorial we chosen IReport. You can download IReport at Follow the instructions to install IReport who you will find at the same website.

Prepare IReport
After you installed IReport, you need to add the classpath with the JDBC drivers you use. • • Choose [Options -> Classpath] and after that [Add Jar] and select the JDBC-driver whose necessary for your database (b.v. C:\......\ After adding the filename you choose[Save Classpath]. Define connections . Choose [Data -> Connection / Datasources] and add the necessary connections. (Look for examples at the Servoy preferences).

Jasper call in Servoy.
To call JasperReport you write the following statement in your script: plugins.jasperPluginRMI.jasperReport(“<server/database>”,”<report>”, ”<outputfile/printerdialog>”,"<outputkind>",<parameters>) <server/database> - name of the server/database e.g controller.getServerName() <report> - name (including absolute / relative path of the setting) of the report with extension. < outputfile/dialog> - in case of ‘viewer’ null - in case of ‘print’ “true/false” for printerdialog (null is also true) - else the name of the file where output will stored < outputkind > - kind of output, possibilities are : view, print, html, xml, pdf < parameters> - in case of parameters you will pass on to the report (see e.g.) Example. var $parameters = new java.util.HashMap(); $parameters.put("version", "4.5.1"); $parameters.put("user_name", globals. userName); $parameters.put("employee_id", employee_id); plugins.jasperPluginRMI.jasperReport(controller.getServerName(),"employees.jasper",null,"v iewer",$parameters);

Sign up to vote on this title
UsefulNot useful