Friday, March 18, 2011

#JasperReports + #SpringRoo = #Jasperoo

For Immediate Release

DigitalFace has released the jasperoo code to the community under GPL3.

What? You say you've never heard of it before? Well, that's not too surprising, I only dusted off the last of the critical functionality last night. ;o)

There are still features missing, and a few little bugs, but I didn't want to work on it any longer without checking it into source control, and since I planned to make this a open source project, I figured that now is the time for its release.

What is jasperoo, and why should I care?
If you don't use Spring Roo, then you probably won't care... just carry on with your life.

If you have started using Spring Roo (or if you've been reading my posts lately), then you already know that it is very powerful for quickly stitching together the components needed for Enterprise Java applications. Jasperoo facilitates the integration of Jasper Reports into your Spring Roo applications.

Let's say that you have created the PetClinic application and would like to have a report that generates a list of Owners. Without jasperoo, you would need to:
  • Add the JasperReports dependencies to your pom.xml;
  • Add the jasperreports-maven-plugin to your pom.xml;
  • Create the ReportController to handle the report requests;
  • Create your jrxml template; and 
  • Wire it all together.
With jasperoo, after it is installed, you just have to call:
  • jasperoo setup
  • jasperoo add --type ~.domain.Owner
Do you want to try it out?
Ok... here we go. I will assume that you have already setup Spring Roo, and familiarized yourself with it. If not, go to the Spring Roo website for instructions.

Step 1 - Create a sample application.
mkdir clinic
cd clinic
roo
    ____  ____  ____
   / __ \/ __ \/ __ \
  / /_/ / / / / / / /
 / _, _/ /_/ / /_/ /
/_/ |_|\____/\____/ 1.1.2.RELEASE [rev fbc33bb]


Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER.
roo> script --file clinic.roo
Step 2 - If you already have an older version of jasperoo installed do the following, otherwise, skip to step 3.
roo> addon remove --bundleSymbolicName ca.digitalface.jasperoo
Step 3 - Install the latest version of jasperoo
roo> osgi start --url http://s.digitalface.ca/jasperoo-latest
Step 4 - Setup jasperoo
roo> jasperoo setup
Step 5 - Generate a report of the Pet Owners
roo> jasperoo add --type ~.domain.Owner
There... that wasn't so hard, was it?

Test your work
Now either exit out of roo, or open another command shell and start-up the Pet Clinic application.
mvn tomcat:run
Open your browser and go to localhost:8080/petclinic/
[click to enlarge]

Create a new Owner
[click to enlarge]

Select the PDF report
[click to enlarge]

Open the report in Adobe Acrobat or some other PDF viewer.
[click to enlarge]

Select the Excel Report
[click to enlarge]

Open the report in MS Excel or Open Office Calc
[click to enlarge]

The reports generated are very utilitarian. However they can be readily edited in iReport.

The same code produces pdf and xls files, and with a small change to the menu file you also get csvhtmlodtxml, and rtf formats.

So, I encourage you to download it and try it out. The project is hosted on Google Code: jasperoo.digitalface.ca.

I look forward to your feedback.

No comments:

Post a Comment