pumaking Posted January 27, 2012 Share Posted January 27, 2012 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}!=0Does someone know the syntax? Link to comment Share on other sites More sharing options...
augarte Posted January 27, 2012 Share Posted January 27, 2012 Hi, Make sure that your fields are Integer type becasue otherwise will not work(($F{Field1}==1 && $F{Field2}!=0) ? Boolean.TRUE : Boolean.FALSE)Hope this helps,Regards. Link to comment Share on other sites More sharing options...
mwatkinson Posted January 27, 2012 Share Posted January 27, 2012 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. Link to comment Share on other sites More sharing options...
pumaking Posted February 2, 2012 Author Share Posted February 2, 2012 Thanks for your help so far.The problem is that I have a string and a bigdecimal field. So is this impossible? Link to comment Share on other sites More sharing options...
augarte Posted February 2, 2012 Share Posted February 2, 2012 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now