Or condition in field "Print when Expression" for frame

0

In the Print when Expression field, I put the following condition to show or hide the frame:

IF((($F{imp_item_revision_id_1}.isEmpty()==false) || ($F{sol_item_revision_id_1}.isEmpty()==false)), Boolean.TRUE,Boolean.FALSE)

If one of the two conditions is true, the frame should be displayed.
But if the first is false and the second is true, in this case the frame disappears. I dont understand why? 
 

ye_l's picture
2
Joined: Mar 12 2019 - 1:11am
Last seen: 1 week 5 days ago

2 Answers:

0

Why so complex syntax? 

Just try:

!$F{imp_item_revision_id_1}.isEmpty() || !$F{sol_item_revision_id_1}.isEmpty()

for your printWhenExpression to let the frame printed when one of the two field isn't empty

Be aware if the field contents are null ... then you could use apache StringUtils.isNotEmpty Method that is "null-safe":

eg:

StringUtils.isNotEmpty($F{imp_item_revision_id_1}) || StringUtils.isNotEmpty($F{sol_item_revision_id_1})

hth + regards

C-Box

C-Box's picture
1142
Joined: Jul 19 2006 - 5:58pm
Last seen: 1 day 14 hours ago
0

It may be that you have a null in $F{sol_item_v}. This will cause .isEmpty() to be null so the condition would be false.

Try this.

Objects.nonNull($F{imp_item_revision_id_1}) && Objects.nonNull($F{sol_item_revision_id_1}) && ($F{imp_item_revision_id_1}.length() + $F{sol_item_revision_id_1}.length() > 0)

 

hozawa's picture
39277
Joined: Apr 24 2010 - 4:31pm
Last seen: 2 hours 8 min ago
Feedback