How to make condition in iReport if there is no one of the values

Asked

Viewed 169 times

1

I have an expression like $F{nome_pai} + " e de " + $F{nome_mae} in a declaration only which sometimes does not have the name of the father or mother in the database and the text casado, filho de e de ...

How not to make the e de if no such name exists.

1 answer

0

You can do it this way:

${nome_pai}.equals("")?(${nome_mae}.equals("")?"":${nome_mae}):
${nome_pai}+(${nome_mae}.equals("")?"":" e de "+${nome_mae})

Explaining...

The first part: If the father’s name is empty, we will check whether the mother’s name is empty or not, if it is empty both names as you can see in the condition will not write this part if it has only the mother’s name respectively wrote the mother’s name.

The second part: If the father’s name is not empty, we write the father’s name respectively, and check if it has the mother’s name, if it has not written anything, otherwise we add " e de " concatenamos with the mother’s name.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.