Concat two String in JSF EL expression [duplicate]
Asked Answered
H

2

47

I have the following el expression:

<af:outputText value="#{viewArticle.publish ? ('Publish on ' + viewArticle.publishDate + ' by ' + viewArticle.publishFirstName + ' ' + viewArticle.publishLastName) : 'Draft version'}"/>

But I am getting

java.lang.NumberFormatException: For input string: "Publish on "

How can I join the string?

Harless answered 14/6, 2013 at 6:46 Comment(6)
You have to write your own EL string concat function, because EL understands + as an arithmetic operation.Top
@refrigerator that means in el this kind of function not available?Harless
Actually you can, if the EL version is 2.0+ using concat method, which version of ADF Faces are you using?Top
@refrigerator I have ADF 11.1.1.6.0 which use jsf 1.2Harless
technology.amis.nl/2012/01/17/… this will help you :)Top
You have to write a custom EL function. This example will help you :)Top
B
88

You can use the String.concat function:

<af:outputText value="#{viewArticle.publish ? 'Publish on '.concat(viewArticle.publishDate).concat(' by ').concat(viewArticle.publishFirstName).concat(' ').concat(viewArticle.publishLastName) : 'Draft version'}"/>

Backler answered 4/11, 2013 at 22:38 Comment(0)
S
44

You should write

value  = "#{someBean.aProperty}  something you want in between #{someBean.anotherProperty}"
Stoke answered 14/6, 2013 at 6:50 Comment(1)
That works for the attribute but does not help if you need the concatenated string as a function parameter in a JSF ELIncertitude

© 2022 - 2024 — McMap. All rights reserved.