Jump to content
We've recently updated our Privacy Statement, available here ×

Boolean expressions


Recommended Posts

By: Romy Yuliawan - snricek

Boolean expressions

2002-02-20 02:14

Hi,

Is it posible to make 2 boolean expressions at <printWhenExpression> tag ?

 

I've got an error when I try to compile tag as follow::

 

<printWhenExpression>new Boolean(($F{FieldName1} != "0") && ($F{FieldName2} != null))</printWhenExpression>

 

 

Thanks.

 

 

By: Teodor Danciu - teodord

RE: Boolean expressions

2002-02-20 08:57

 

Hi,

 

You could write anything you want in

a JasperReports expression as long as

it represents a valid Java expression

that returns the required type.

 

For "printWhenExpression" the only condition that

applies is that the returned value should be of

java.lang.Boolean type.

 

However, make sure you compare your

java.util.String variables right.

 

When comparing two String objects, you should

use "equals()" and not "!=" or "==" operators.

 

So, your expressions should go like this:

 

<printWhenExpression>

new Boolean( !("0".equals($F{FieldName1})) && ($F{FieldName2} != null) )

</printWhenExpression>

 

Good luck!

Teodor

 

 

 

By: Romy Yuliawan - snricek

RE: Boolean expressions 2

2002-02-20 19:31

Hi,

Sorry for make much questions, but I've still got the error.

 

Parse Fatal Error at line -1 column -1: The entity name must immediately follow the '&' in the entity reference.

 

and it was run when the logical "&&" turn into "||", look like this::

 

new Boolean( !("0".equals($F{FieldName1})) || ($F{FieldName2} != null) )

 

Thanks for you help

 

 

 

By: Teodor Danciu - teodord

RE: Boolean expressions 2

2002-02-21 00:57

 

Hi,

 

Sorry, my mistake.

 

'&' is a special character that is interpreted

by the XML parser.

To avoid this, put the expression between

a sequence like the following:

 

<groupExpression>

<![CDATA[

new Boolean( !("0".equals($F{FieldName1})) && ($F{FieldName2} != null) )

]]>

</groupExpression>

 

Good luck!

Teodor

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...