Hi,
due to my lack of Java/Groovy knowledge I have to ask how to create a printwhen expression with a and/or condition.
Example:
$F{Field1}==1 and $F{Field2}!=0
Does someone know the syntax?
4 Answers:
Just a minor addition, I recently had a problem with conditional statements and subreports. i recommend this minor change to augarte's suggestion:
(($F{Field1}==new Integer(1).intValue() && $F{Field2}!=new Integer(0).intValue()) ? Boolean.TRUE : Boolean.FALSE)
It appears that at least in version 4.1.3 failure to explicitly define a integer value as such can in some circusmstances result in it being treated as a string value, thereby causing a class cast exception at runtime.
Hi,
Not sure how could yo do this, maybe this could work:
(($F{Field1}.intValue () ==new Integer(1).intValue() && Integer.parseInt($F{Field2})!=new Integer(0).intValue()) ? Boolean.TRUE : Boolean.FALSE)
In this case I assume that Field1 is BigDecimal and Field2 is string type.
Hope this helps.
Regards.