How to make condition in iReport perhaps not one of the values

1

I have an expression of type $F{nome_pai} + " e de " + $F{nome_mae} in a statement only sometimes does not have the parent's name in the database and gets the text casado, filho de e de ...

How do not show e de if one of the names does not exist.

    
asked by anonymous 16.02.2016 / 23:28

1 answer

0

You can do this as follows:

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

Explaining ...

The first part: If the name of the parent is empty, we will check if the name of the mother is empty or not, if both names are empty as you can see in the condition will not write this part, if he had only the mother's name, respectively, he had written the mother's name.

The second part: If the name of the parent is not empty, we write the name of the parent, and we verify if it has the name of the mother, if not, we did not write anything, with% concatenamos with the name of the mother.

    
10.05.2016 / 22:43