Wednesday Jan 31, 2007
Wednesday Jan 31, 2007

We just published a new Visual Web Pack tutorial, Generating Reports and PDFs From a Web Application that shows how use JasperReports to generate HTML and PDF reports from a data source. JasperReports is a reporting tool that outputs reports in HTML, PDF, XLS, CSV, and XML formats. This tutorial provides code, which you can copy to any project's application bean, that fills a report with the same query result that you use to populate the JavaServer Faces components on a page. The tutorial also shows how to modify the build script to compile the JasperReport templates.
Thanks to Craig Conover and Marina Sum who forged the trail with their tutorial on using JasperReports with the NetBeans IDE, and to Craig McClanahan who made sure my sample code followed the "best practices".
Geertjan just blogged on a JasperReports Visual Designer for the NetBeans IDE. I look forward to exploring this designer and finding out how this designer integrates with Visual Web applications.
Tuesday Jan 30, 2007
I just finished writing a NetBeans Visual Web Pack version of the JasperReports tutorial Generating Reports and PDFs From a Web Application. The NetBeans version should appear on the portal sometime today.
While working on this tutorial, I came across a bug that prevented the company logo from appearing in the HTML output when the application is deployed to version 9 of the Sun Java System Application Server. The bug happens when you request binary data through the FacesServlet, and the fix is in for version 9.1. Ryan and Craig were the engineers who figured out why the problem was happening. They both pointed out to me that the following statement in my code sample, which sets a relative url, is not recommended:
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image=");
The above statement results in following HTML:
http://localhost:8080/TravelReport/faces/image?image=img_0_0_0
By using the relative URL, I was needlessly incurring, for a non-JavaServer Faces entity, the extra overhead that is associated with a JavaServer Faces request. It is better to serve up the image directly, instead of going through the JavaServer Faces lifecycle.
I am pushing out a new version of the Java Studio Creator tutorial today, which shows the correct way to pass the url (which happens to work with Sun Java Application Server 9):
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,
request.getContextPath() + "/image?image=");
While we are talking about server bugs, a customer wrote to me that they were getting a java.lang.NullPointerException from the javax.faces.component.UIComponentBase class's getRenderer method whenever they use the Table component in web applications deployed to JBoss. This is a known bug, and is documented in the Release Notes. What is happening is that when you create a Visual Web project, the classpath on the container is checked. If the IDE finds a MyFaces implementation, it gives the MyFaces implementation precedence over the JavaServer Faces Reference Implementation libraries. To prevent this problem from happening, delete or move the JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/jsf-lib directory before you create the Visual Web Pack project for that container. This forces the the IDE to bundle the JSF Reference Implementation with the project.
To go back to using the MyFaces run time for running non-Visual Web Pack based applications, follow these steps:
<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener
</listener-class>
</listener>
Monday Jan 08, 2007
A few customers have pointed out a bug in the Generating Reports and PDFs From a Web Application tutorial. I have to admit that I am somewhat embarrased that I never noticed that the first record is missing from the reports.
I am trying to get the fix pushed out this week. In the meantime, for those who are using code from the tutorial, you should know that you need to either call beforeFirst() or execute() on the rowset before passing the rowset to the JRResultSetDataSource constructor.
Tuesday Nov 21, 2006
We just posted the http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/reports.html tutorial to the Sun Java Studio Creator Tutorials web site. This tutorial works for the Visual Web Pack with the following changes.
reports.src (that is, the "src" directory inside the project)
so that this node will be parallel to src/java.src/reports node, and click Open.JasperReports Definitions and click OK.src/reports).