Using JasperReports with opentaps

From Opentaps Wiki
Revision as of 21:49, 25 October 2007 by Sichen (talk | contribs)
Jump to navigationJump to search

With opentaps, you can define reports with JasperReports either manually or using the iReport report writer and then upload them to the opentaps server for processing.

To use Jasper in your custom application you should incorporate the view handler in your controller.xml:

 <handler name="jasperreports" type="view" class="org.opentaps.common.reporting.jasper.JasperReportsViewHandler"/>

This view handler will render the jasper reports XML file in a variety of formats available. Then, upload your reports into the opentaps webapp/ in a sub-directory and define view-map for your report:

  <view-map name="MyReport" type="jasperreports" page="/reports/MyReport.jrxml" content-type="application/pdf" encoding="none"/>

Possible values for content-type are application/pdf, text/html, text/csv, application/rtf, text/plain, application/vnd.oasis.opendocument.text This is a default content type in case the report itself does not specify one.

When the report is run on the opentaps server, the data could be prepared by a beanshell (.bsh) script and generated using the entity engine. This would override the SQL in the jrxml itself. You can also reference internationalized UI labels within your jasper reports by using $R{...} syntax, such as:

   $R{FinancialsReport.TotalSales.Title}

which would reference the FinancialsReport.TotalSales.Title in the FinancialUILabels.properties file.