Concat two String in JSF EL expression [duplicate]

2019-03-17 07:37发布

This question already has an answer here:

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?

3条回答
【Aperson】
2楼-- · 2019-03-17 07:45

You have to write a custom EL function. This example will help you :)

查看更多
Luminary・发光体
3楼-- · 2019-03-17 07:53

You should write

value  = "#{someBean.aProperty}  something you want in between #{someBean.anotherProperty}"
查看更多
你好瞎i
4楼-- · 2019-03-17 08:03

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

查看更多
登录 后发表回答