Featured Post

The great debacle of healthcare.gov

This is the first time in history when the president of the United States of America, or probably for any head of state around the world,...

Thursday, January 7, 2010

BIRT: 10 tips and tricks

1. Custom Sorting order

Convert the Text values into numbers and do the sorting in the Group sort, when Grouping is been used.

e.g.

if(row["COLUMN_VALUE"] == 'First')
1;
else if(row["COLUMN_VALUE"] == 'Second')
2;
else if(row["COLUMN_VALUE"] == 'Third')
3;
else if(row["COLUMN_VALUE"] == 'Fourth')
4;
else if(row["COLUMN_VALUE"] == 'Fifth')
5;
else if(row["COLUMN_VALUE"] == 'Sixth')
6;

2. BIRT viewer is misleading

2.1. The DataSet maximum fetch records parameter don't actually abide by the BIRT viewer. But when the same report deployed to the server or being processed in web application, they really matter. For example, if the fetch size is 20 in a DataSet, the BIRT viewer would show all records but in the real application DataSet would restrict itself to retrieve up to 20 records

2.2. Presentation of images in a Grid shows wrongly aligned on the BIRT viewer but when deployed in the Application, they're simply perfectly aligned.

2.3 BIRT viewer (2.2) doesn't reload with new parameter values when trying to rerun with new set of parameter selection. It needs to start over every time parameters needs to be changed for testing purpose

3. Multi select list as parameter values

Unfortunately BIRT (prior to 2.3) doesn't have any straight forward way to use multi select parameter. One way to pass the multi select parameter values is to use the BeforeOpen event of the DataSet, rewrite the SQL to pass the values as part of the WHERE clause, most popularly, IN formed. One thing to remember, BIRT capture the values from the Multi Select parameter as an Array object. So the values needs to be accessed as e.g. names.value[0], names.value[1], etc.

4. Logging

Script the below in the “Initialize” of the report

importPackage(Packages.java.util.logging);

var fileHandler = new FileHandler("log_file_name", true);

var rootLogger = Logger.getLogger("");

rootLogger.addHandler(fileHandler);


Writing to log:

Logger.getAnonymousLogger().info(“this is my log");