46

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?

6
  • You have to write your own EL string concat function, because EL understands + as an arithmetic operation. Jun 14, 2013 at 6:48
  • @refrigerator that means in el this kind of function not available?
    – Tapas Bose
    Jun 14, 2013 at 6:51
  • Actually you can, if the EL version is 2.0+ using concat method, which version of ADF Faces are you using? Jun 14, 2013 at 6:55
  • @refrigerator I have ADF 11.1.1.6.0 which use jsf 1.2
    – Tapas Bose
    Jun 14, 2013 at 7:20
  • 1
    technology.amis.nl/2012/01/17/… this will help you :) Jun 14, 2013 at 7:22

2 Answers 2

86

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'}"/>

44

You should write

value  = "#{someBean.aProperty}  something you want in between #{someBean.anotherProperty}"
1
  • 1
    That works for the attribute but does not help if you need the concatenated string as a function parameter in a JSF EL
    – cljk
    Oct 8, 2020 at 11:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.