payal
payal

Reputation: 251

Jasper reports - iReport - page number variable doesn't work

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")

Upvotes: 0

Views: 8553

Answers (1)

Jmini
Jmini

Reputation: 9497

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)

Upvotes: 2

Related Questions