views:

1953

answers:

3

Hi ,

this is my expression code ;

($F{Personel_ODEME}.equals(Boolean.TRUE)) ? "PAID" : "NO PAID"

if Personel is paid her/his tax jasper report will write PAID else NO PAID in Report.But in DB this field is BOOLEAN Type but expression is returning string type. SO i am getting "Can not cast from String to Boolean" error. how can i solve this guyz ?

+3  A: 

The problem stems from your test $F{Personel_ODEME}.equals(Boolean.TRUE), which Jasper is thinking is a String to Boolean comparison, and doesnt like. To fix this, try this:

($F{Personel_ODEME}.equals(Boolean.TRUE.toString())) ? "PAID" : "NO PAID"

This will result in a String to String comparison.

It is good to note that In Java, a "true".equals(Boolean.TRUE) would result to false.

edit:

This appears to be a Jasper 'PrintWhen' expression, which allows you to determine whether to print the contents of a cell or not. It is expecting Boolean.TRUE or Boolean.FALSE as its return values. When you return "PAID", Jasper tries to evaluate that String as a Boolean, which it cant, so it throws the exception.

akf
I believe you mean - "true".equals(Boolean.TRUE)
Jack Leow
@Jack Leow: that is exactly what i mean. thanks. edited.
akf
nope this no fix my problem. $F{Personel_ODEME} is BOolean field i cant use toString method.Gettin same error.
Ibrahim AKGUN
I know what is the problem but how can i solve it ? Is there any way to fix this ?
Ibrahim AKGUN
+1  A: 

ok i fixed it . i have changed $F{Personel_ODEME's type to STRING .. than its worked like a charm. thanx.

Ibrahim AKGUN
A: 

I have a similar problem, it's not a cast problem but when Jasper evaluate a boolean, it always set the value to false:

Any Ideas ?

Giovanni
You should open a question for this
Tim Büthe