How to use Grails with a BIRT message and show a BIRT webview

I installed the birt-report plugin on the Grails web application project, but I cannot use it. I have 2 use cases:

  • Generate BIRT webview and show on GSP page (Show graph report)
  • Generate a BIRT report in a different file format (PDF, Word, etc.).

Can you provide examples of how to do this?

+5
source share
1 answer

, (http://grails.org/plugin/birt-report). 1. HTML-. , BIRT HTML, GSP. HTML GSP.

// generate html output and send it to the browser
 def show() {
     String reportName = params.remove('id')
     String reportExt = 'pdf'
     params.remove('action')
     params.remove('controller')
     params.remove('name')
     def options = birtReportService.getRenderOption(request, 'html')
     def result=birtReportService.runAndRender(reportName, params, options)
     response.contentType = 'text/html'
     response.outputStream << result.toByteArray()
     return false
 }
  • pdf

    def downloadAsPDF() {     String reportName = params.remove('id')     String reportExt = 'pdf'     params.remove( '')     params.remove( '')     params.remove( '')     def options = birtReportService.getRenderOption(, 'pdf')     def result = birtReportService.runAndRender(_, , )     response.setHeader( "Content-disposition", "attachment; filename =" + reportName + "." + reportExt);     response.contentType = 'application/pdf'     response.outputStream < result.toByteArray()     return false }

0

All Articles