internet
internet

Reputation: 385

How to concatenate strings in conditional operator of an EL expression

I want to concatenate bean.receiver.surname and bean.receiver.name as one string in the following expression. How can I do this?

itemLabel="#{bean.receiver == login.current ? bean.sender.surname : bean.receiver.surname bean.receiver.name}"

Upvotes: 0

Views: 2082

Answers (1)

McDowell
McDowell

Reputation: 108899

Assuming at least EL 2.2 and that the names are non-null Strings you could have an expression of the form:

#{condition ? str0 : str1.concat(str2)}

For an older version (or null Strings) you could use:

#{condition ? str0 : str1}#{condition ? str0 : str2}

Upvotes: 3

Related Questions