Jump to content
Changes to the Jaspersoft community edition download ×

[Solved] OR operator in "Print when expression" field


g.dagostino

Recommended Posts

Good morning to all,

I'm creating an IReport PDF template using the IReport designer version 3.5.0

I 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 operators

new 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, regards

Giuseppe

 

 

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi, 

Try the following: 

!$F{riepilogo_totaleDichiarazioni}.equals( "" ) || !$F{riepilogo_totaleDistinte}.equals( "" ) ? Boolean.TRUE : Boolean.FALSE

Or otherwise this should work also: 

$F{riepilogo_totaleDichiarazioni}.equals( "" ) && $F{riepilogo_totaleDistinte}.equals( "" ) ? Boolean.FALSE : Boolean.TRUE

In 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

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

  1. both fileds are empty
  2. first field (riepilogo_totaleDichiarazioni) is set and the second (riepilogo_totaleDistinte) is empty

but 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...