Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have an error using Jaspersoft Studio with Oracle Database. As soon as there is some data, the following line

<printWhenExpression><![CDATA[$P{REPORT_TYPE}.substring(0,1)=="R"? $F{REASON_DELETED}:$F{REASON_ADOC}]]></printWhenExpression>

throws the following error:

net.sf.jasperreports.engine.JRException: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean

I don't understand, why Jasper Studio would cast it to a Boolean, since it is defined as a String:

<field name="REASON_ADOC" class="java.lang.String"/>
<field name="REASON_DELETED" class="java.lang.String"/>

and the SQL is also fine to me:

NVL(cr.REASON_ADHOC,'-') AS reason_adoc,
NVL(cr.REASON_DELETED,'-') AS reason_deleted,

and also in the view/table:

REASON_DELETED  VARCHAR2(250)
REASON_ADHOC    VARCHAR2(4000)
share|improve this question
up vote 2 down vote accepted

You're right, your expression returns a String. But printWhenExpression expects boolean expression as a content. According to docs:

printWhenExpression Definition of a Boolean expression that will determine if the element or the band should be printed or not.

It's not clear what are you trying to achieve. You might want to use textFieldExpression instead.

share|improve this answer
    
Thank you! I'm sure I get it working now ... should have checked the printwhenexpression class! – Stef Jan 15 '15 at 17:01
    
You're welcome. I'm glad I could help – default locale Jan 15 '15 at 17:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.