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?

Tapas Bose
  • 28,796
  • 74
  • 215
  • 331

2 Answers2

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

albfan
  • 12,542
  • 4
  • 61
  • 80
Marcio Aguiar
  • 14,231
  • 6
  • 39
  • 42
44

You should write

value  = "#{someBean.aProperty}  something you want in between #{someBean.anotherProperty}"
Prasad Kharkar
  • 13,410
  • 5
  • 37
  • 56
  • 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 08 '20 at 11:38