Birt Plugin

Overview

This plugin provides you with the ability to integrate Birt Reporting (http://www.eclipse.org/birt/) into your application.

The plugin currently provides for:

  • PDF Report generation only
  • No previews of report output
  • A Tag Library to help with presenting report parameters in your .gsp pages
  • Automatic binding of form variables to your report parameters

 Installation

The current version of the plugin is 0.1, and is based on version 2.2.0 of the Birt ReportEngine Runtime

grails install-plugin birt

IMPORTANT: Plugin Gotcha

 Your application is likely to throw an exception on startup like the following:

  Error creating bean with name 'pluginMetaManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:

Don't be alarmed. This is because the OSGi also uses plugin.xml for plugin descriptors, just like Grails. The fix is to edit your 

/WEB-INF/applicationContext.xml and change the <pluginMetaManager/>'s constructor-arg to :

  <constructor-arg value="classpath*:/plugins/*/plugin.xml" />

This will restrict your Grails app to only looking for Grails plugins in your "/plugins" folder, and leave stuff under e.g. /WEB-INF/platform alone.

Configure

 There are two config settings for the Birt plugin. Both of these settings should be added to your [conf/Config.groovy]

 Report Engine Home

 The Report Engine Home needs to point to the folder containing your Birt Runtime component. This is typically 

 <app-dir>/WEB-INF/platform

  The config setting for the Report Engine Home is birt.engineHome e.g:

birt.engineHome="/home/stephan/workspace.java/birt-test/web-app/WEB-INF/platform"

 Report Home

  The Report Home needs to point to the folder where you will be storing your .rptdesign and .rptlibrary files . This is also the folder

  where your .pdf documents will be generated into. You can place this anywhere on your filesystem accessible by your

  application server.

  The config setting for Report Home  is birt.reportHome e.g:

  birt.reportHome="/home/reports"

   

  Using

It is fairly straightforward to generate a report. A single method call to the ReportEngineService takes care of it.

The following code snippet is from the example application which can be downloaded HERE

class ReportController {
    def reportEngineService
    def runReportNow = {
        try {

            def PDFFilename = "my_test_report.pdf"
            def reportFilename = "my_test_report.rptdesign"

            reportEngineService.runPDFReport(reportFilename, PDFFilename, params)

            flash.message = 'Your report executed successfully.'

            render (view: 'report_result', model:[filename: PDFFilename])


        }catch(Exception ex){

            flash.message = 'An error has occured while running your report'

            ex.printStackTrace()
            render (view: 'report_result', model: [error: true] )

        }

    }
   

}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.