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
3
Joined: Mar 12 2019 - 1:11am
Last seen: 4 weeks 29 min ago

3 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
1326
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 hours 56 min 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
42177
Joined: Apr 24 2010 - 4:31pm
Last seen: 6 hours 44 sec ago
0

Hello C-Box, hello hozawa,

thank you very much for your help. Your suggestions have helped me a lot!

best regards

yel

ye_l's picture
3
Joined: Mar 12 2019 - 1:11am
Last seen: 4 weeks 29 min ago
Feedback