views:

1112

answers:

2

I have to prepare a letter in which i require a 40 mm page header for first page and 20mm page header for all other pages except the first page. So I've created 2 page headers. I want to hide/show the page headers based on the page number. But when I write the following print when expression, it doesn't work. $V{PAGE_NUMBER}.equals ("1"). Please help.

+2  A: 

You need to check what the type of $V{PAGE_NUMBER} is... (I think it is java.lang.Integer)

The method you choose return a boolean an a PrintWhenExpression should return a java.lang.Boolean, so you need to instantiate one.

Try :

new Boolean($V{PAGE_NUMBER}.equals("1"))

It should work... To improve your test, I think that it is better to make a int comparison (a Java specialist should confirm that)

new Boolean($V{PAGE_NUMBER}.intValue() == 1)

The other manipulation you might have to do is specifying the whole object name (I don't know how JasperReport deals with import)

new java.lang.Boolean($V{PAGE_NUMBER}.intValue() == 1)
Jmini
A: 

Thanx! The last option work perfectfor me!

DGB
use comments, not answers. and mark the answer as accepted, if it worked for you
Bozho