concat and NULL

Hi,

I have a problem with concatenation of two strings (from query) in a textfield.

I want to concat string A and B with a " - " between them. The "-" is present only if B is not NULL.

I use the following expression in the textfield :

Code:
<br />
(!($F{A}.equals(null)) ? $F{A} : ""«») +<br />
(!($F{B}.equals(null)) ? " - " + $F{B} : ""«») <br />
</td></tr></tbody></table><br />
<br />
But it doesn't work. If B is NULL, nothing is printed (normally A must be printed).<br />
<br />
Can you help me ?<br />
Thanks<br>Post edited by: babarincairo, at: 2006/11/07 08:25
babarincairo's picture
Joined: Sep 10 2006 - 11:59pm
Last seen: 17 years 2 weeks ago

3 Answers:

I think that the following code will work :

Code:
($F{A} == null ? "" : ( $F{B} == null ? $F{A} : $F{A} + " - " + $F{B} )) </td></tr></tbody></table>
jpasquier's picture
232
Joined: Sep 19 2006 - 5:01pm
Last seen: 8 years 8 months ago
the folloling code is working


($F{NOT_zone1}) +
($F{NOT_zone2} == null ? "" : " - " + $F{NOT_zone2}) +
($F{NOT_zone4} == null ? "" : " - " + $F{NOT_zone4}) +
($F{NOT_zone5} == null ? "" : " - " + $F{NOT_zone5}) +
($F{NOT_zone6} == null ? "" : " - " + $F{NOT_zone6})
babarincairo's picture
Joined: Sep 10 2006 - 11:59pm
Last seen: 17 years 2 weeks ago
Everyone, this is the only solution for that issue? Can't this be simplified using Groovy?
DerGuteMoritz's picture
Joined: Dec 27 2006 - 10:48am
Last seen: 16 years 9 months ago
Feedback