Reputation: 305
I need to show a static text field only if the price value is not null, i tried to do this:
<printWhenExpression>
<![CDATA[$F{price} != null]]>
</printWhenExpression>
But this not works, it's always returns true with Double value, in a String value it worked.
Edit: The code started to works, I will keep this because the helpfull reply.
Upvotes: 0
Views: 1478
Reputation: 21710
This is not true if the $F{price}
is null
the expression will return false
.
Maybe you do not need to check for that is null
but that it is not Double.NaN
<printWhenExpression>
<![CDATA[new Boolean($F{price} != null && !$F{price}.isNaN())]]>
</printWhenExpression>
I suggest you output the value of $F{price}
, to understand what it is...
NOTE: I'm using new Boolean() for compatibility reasons (jasper report v 3) this is not needed in jasper report v 5,6
Upvotes: 1