Hi,
Can somebody tell me how to use the printwhenexpression of jasper?
Regds, malathi
Hi,
Can somebody tell me how to use the printwhenexpression of jasper?
Regds, malathi
Do you have an error relative to boolean ?
Because you need to use Boolean instead of the primitive type.
So:
$F{mesure} != "PH"
($F{userfd4}).equals("1") ? true : false
would give cannot cast from boolean to Boolean
.
( $F{mesure}.startsWith("PH") ? Boolean.TRUE:Boolean.FALSE )
($F{userfd4}).equals("1") ? Boolean.TRUE : Boolean.FALSE
would be correct.
See also this example
The other poster has done a good job of explaining the technical details of how to use it, so I'll try and explain the circumstances in which one might find it useful.
Basically, it allows you to show or hide the contents of a cell based on a boolean expression. For example, you might want to show a person's name only if that person is over 18, then in the name field, using a printwhenexpression like:
$F{age} >= 18
You can also use the static method "Boolean.valueOf(boolean b)". It does exactly the same logic as "($F{mesure}.startsWith("PH") ? Boolean.TRUE:Boolean.FALSE)" and good rule of thumb is don't recreate the wheel.
Boolean.valueOf($F{mesure}.startsWith("PH"))
Boolean.valueOf($F{userfd4}).equals("1"))
i try to do the same as code above. But it cannot work correctly. The result display blank. Below is my DB structure:
O 45
P 1000
T 4500
how to display the value of share_amount using "Print When expression" func ?
My expression code is like this :
Boolean.valueOf($F{SHARE_CLASS_CD}.startsWith("P")) ---> to display 1000 (share_amount)
Boolean.valueOf($F{SHARE_CLASS_CD}.startsWith("O")) ---> to display 45 (share_amount)
Boolean.valueOf($F{SHARE_CLASS_CD}.startsWith("T")) ---> to display 4500 (share_amount)