optional parameters in Jasper reports

I have been mainly writing Jasper reports this week. There seems to be a dearth of documentation (unless you pay for ‘The Definitive Guide’), but a combination of iReport and trial and error seems to be working.

I wanted to reuse the same report with some optional parameters – add an additional condition to the where clause if a certain paramteter was supplied. I realise that I can pass an entire SQL statement into the report, or even some objects containing the data, but I like the consistency of having valid SQL in the report and letting Jasper substitute the parameters appropriately.

My solution was to use the ‘case’ statement (I’m using PostgreSQL):

WHERE manager = (case when $P{manager} != '' then $P{manager} else manager end)

I guess there would be performance implications on a big dataset, but it seems to work.

java.lang.NoSuchMethodError: javax.servlet.ServletResponse.getContentType()

On windows XP when I start Tomcat 5.5.27 throught the eclipse plugin, and try to view a JSF app in a browser. When I start Tomcat at the command line it seems to be fine, but then I can’t use the Eclipse debugging features etc.

I guess Eclipse is including some innappropriate jar files in the classpath or something, but I’ve no idea where to look :(

Agilefant?

After all that fiddling with xplanner, we decided to use Agilefant (The Finnish Ferrari for backlog management!) instead. It requires JDK 1.6, Tomcat 5.5 and MySQL. I think it would work with PosgreSQL, but no database script was provided. It worked straight away (all we had to do was create the database and put the war file into the webapps directory) and seems to be under current development, which is 2 up on xplanner already! It seems quite new and I’m not sure that it has been widely adopted, so we’ll see how we get on.

Getting Xplanner working

Xplanner is a project planning and tracking tool for agile development teams, which we’ve been recommended to use at work. The only problem is, no-one seems to have done any work on it since 2006, and it only officially works in jdk 1.4, and some old version of Tomcat. Our server runs PostgreSQL 8, Tomcat 5.5 and jdk 1.6. One of the main problems we had was that the automatic migration process did not seem to work for Postgres. This is what I did to get it to work:

  1. Downloaded version 0.7b4. Amended xplanner-custom.properties to point to the postgres database. Used ant to install the database.
  2. Downloaded version 0.7b7. Followed installation instructions.
  3. Patched the database myself. The scripts are inĀ  WEB-INF\classes\patches. I had to amend them to work with Postgres (e.g. datetime -> timestamp, tinyint -> boolean). I only had to run the later ones.
  4. Deleted the patch scripts
  5. Deleted the file \WEB-INF\classes\com\technoetic\xplanner\upgrade\CleanUpNoteTableConstraints.class as it didn’t seem to like this either.
  6. Followed these instructions: http://espritlibre.org/2008/07/10/xplanner-spring-and-jdk-16/

And after all that, it seems to work, phew!