So I am using Groovy on Grails in my work now. I would say I love this new friend due to his high productivity. I have been playing around with Groovy and Grails for the past 2 months. Not many good documentation out there (the official documentation is just too brief), so I encountered many problems.
Once I was asked to find the way to build reports for our clients and integrate those reports into our Grails application. We looked at Jasper Report, an open source Business Intelligence platform, because it has a plugin for Grails.
My first attempt is to install iReport 3.7.1 for report layout, jasperserver for managing reports on server. Since I had experience with SQL reporting server, iReport caused me no problem (it is not bad). To make the jasper server up I downloaded the jasperserver.jar and deployed it to glassfishv3 just to realized that it is only supported by glassfish 2. So I went for alternative: Tomcat 6 and the reporting server was up. The jasper sever provide you with nice GUI to manage your reports. With jasper server plugin, you can even connect with your server from iReport.
However, now it comes to another problem, how to integrate the jasper server into my current application, in particular how to merge the access control of application and jasper report.
I investigated further and discovered a great blog which provides you with a nice solution. The solution is elegant. He created 2 domain classes for report and report parameters. When you want to create a report, you will need to define report parameters first. His code has 2 types of parameters: textbox or date. I feel it is not complete since many times we will need to have a dropdown list in the report for user to choose from. Therefore, I customized the code to add in this third type. This thing which i can nicely integrate into my app only helps you to handle report parameter definition. The report layout will be created by iReport which is separated from the application. I also dropped the iReport software but installed the iReport plugin for Netbeans, so that I do not have to switch back and forth between Netbeans and iReport.
So iReport create .jrxml files with layout and data query. You will need to install jasper plugin for grails to run the .jrxml files and produce the actual reports on format of your choice (pdf, xls, text, csv,…)
Other than that, take note that the jasper plugin used the outdated version of jasperreport library, so you will need to update it by replacing the jasper report jar library in plugin folder with the lastest version (3.7.1) and also update iText.jar file.
Ok, now you have reasonable solution to the report issue for a grails application.
Great post, however could you add the link for the other blog post you’re talking about?