Integrating Sample Jasper Report in WaveMaker Application
note
Content in this page was outdated. Use Connector approach instead writing Code. Click here to see How-to use Jasper connector in WaveMaker App
Jasper Reports is an open source Java reporting tool that can write to a variety of targets, such as: screen, a printer, into PDF, HTML, Microsoft Excel, RTF, ODT, Comma-separated values or XML files. It can be used in Java-enabled applications, including Java EE or web applications, to generate dynamic content.
- To Integrate Jasper Reports in your WaveMaker application you will need to write the Java Service where by passing required parameters one can generate the report. Refer the link for creating Java service.
- In this example the Java Service will take database and jrxml file (JasperReports reports are defined in an XML file format, called JRXML) as input and create the pdf report.
Prerequisites
- Add Jasper as dependency in pom.xml along with required exclusions: Here is the relevant section that needs to be added by the developer. Adding the below dependency in
pom.xml
, will automatically download the specified.jar
file from the repository and place it in the lib folder of the corresponding project.
- Create a database with a table named
employee
with the following DB Schema and add sample data.
- The
jrxml
file has to be created as per your database. Import thejrxml
file toprojects/src/main/resources
. For the above database, we have used the following employee.
Steps in Integration
- Java Service Integration will create sample Java Service.
- Add the below method
generatePdfReport
to the Java Service.
- Add the following
import files
.
note
Some of these import files will be available already in the sample Java Service.
- Open/Create the page where you need to include the Jasper report.
- Create a Java Service Variable with the following.
- Service as
MyJavaService
(the Java Service name created in step-1). - Method as
generatePdfReport
(the method name added in step-2).
- Service as
- Navigate to the
Data
tab.- For
jrxml
field enteremployee.jrxml
(the file name added as per prerequisite2). - For
database
field enteremployee
(database for which the report needs to be generated).
- For
- To display the pdf file, drag and drop
iframe
widget and set the Source property to the following.
services/myJava/generatePdfReport?jrxml=employee.jrxml&database=employee