g.dagostino Posted April 24, 2013 Share Posted April 24, 2013 Good morning to all,I'm creating an IReport PDF template using the IReport designer version 3.5.0I have to print a static text if at least one of two variables are not blank: so in the "Print when expression" field of my static text I wrote this condition new Boolean( !$F{riepilogo_totaleDichiarazioni}.equals( "" ) || !$F{riepilogo_totaleDistinte}.equals( "" ) )It works only if the first operator is true, but if the first is false and the second is true the condition doesn't work. If Itry to reverse the two operatorsnew Boolean( !$F{riepilogo_totaleDistinte}.equals( "" ) || !$F{riepilogo_totaleDichiarazioni}.equals( "" ) )it works just if the variable "riepilogo_totaleDistinte is valued. So it seems that the expression evaluate only the first operator and ignores the second.Is there something wrong in my code?Thanks in advance for your replies, regardsGiuseppe Link to comment Share on other sites More sharing options...
augarte Posted April 24, 2013 Share Posted April 24, 2013 Hi, Try the following: !$F{riepilogo_totaleDichiarazioni}.equals( "" ) || !$F{riepilogo_totaleDistinte}.equals( "" ) ? Boolean.TRUE : Boolean.FALSEOr otherwise this should work also: $F{riepilogo_totaleDichiarazioni}.equals( "" ) && $F{riepilogo_totaleDistinte}.equals( "" ) ? Boolean.FALSE : Boolean.TRUEIn this case what you are saying is that the text shoulnd't be printed if both fields (riepilogo_totaleDichiarazoni and riepilogo_totaleDistinte) are empty strings.Hope this helps.Regards Link to comment Share on other sites More sharing options...
g.dagostino Posted April 24, 2013 Author Share Posted April 24, 2013 First of all...thank you for your reply!I tried the second solution ($F{riepilogo_totaleDichiarazioni}.equals( "" ) && $F{riepilogo_totaleDistinte}.equals( "" ) ? Boolean.FALSE : Boolean.TRUE) and it works fine if both fileds are empty first field (riepilogo_totaleDichiarazioni) is set and the second (riepilogo_totaleDistinte) is emptybut doesn't work fine if the first field is empty and the secondo in set. It seems not evaluate the second condition after the && operator.Any suggestion? Link to comment Share on other sites More sharing options...
augarte Posted April 24, 2013 Share Posted April 24, 2013 Which is the value of the second field when it doesn't work? Are both fields string type? Could you attach your .jrxml file? Link to comment Share on other sites More sharing options...
g.dagostino Posted April 24, 2013 Author Share Posted April 24, 2013 The value of the second filed when it doesn't work is a numeric string (es 5). Both fields are string type.I attach the .jrxml file. The involved static text is the first "N°" in the right side of the report.Thank you for your help!Regards,Giuseppe Link to comment Share on other sites More sharing options...
augarte Posted April 24, 2013 Share Posted April 24, 2013 Your are using an xml file as datasource right? If so, could you also attach the file in order to test your report? Link to comment Share on other sites More sharing options...
sanbez Posted April 24, 2013 Share Posted April 24, 2013 Try like this: ($F{FIRST} != null && !$F{FIRST}.equals(""))||($F{SECOND} != null && !$F{SECOND}.equals("")) Link to comment Share on other sites More sharing options...
g.dagostino Posted April 24, 2013 Author Share Posted April 24, 2013 Thank you sanbez your solution works fine...I had to check also the null value!Thank you augarte for your time! 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