Boolean expressions

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
2001 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:26am
Last seen: 17 years 1 month ago

0 Answers:

No answers yet
Feedback