Wednesday, February 01, 2006

Comparing Integers for JasperReports

Sometimes, you might want to display a different band depending on the record count. As usual, the solution is slightly convoluted because JasperReports doesn't use primitives anywhere (I feel so bad for the non-Java programmers who have to write reports with it). I set the following "Print when expression" for the text field:
new Boolean( ($V{REPORT_COUNT}).equals(new Integer(0)) )
Note that the evaluation time Of course, if the JP developers used primitives, it would just be $V{REPORT_COUNT} == 0 but why make it that easy!?!
This works too:
new Boolean( 0 == ($V{REPORT_COUNT}.intValue()) )

Note that the Evaluation time must be set correctly. For example, if you put the above in the title bar, and set evaluation to now, REPORT_COUNT will always be zero.

No comments:

Labels

Blog Archive

Contributors