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?
You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
The “+” operator with a String acts as a concatenation operator. Whenever you add a String value to a double using the “+” operator, both values are concatenated resulting a String object. In-fact adding a double value to String is the easiest way to convert a double value to Strings.
Use CONCATENATE, one of the text functions, to join two or more text strings into one string. Important: In Excel 2016, Excel Mobile, and Excel for the web, this function has been replaced with the CONCAT function.
Java - String concat() Method The method returns a String with the value of the String passed into the method, appended to the end of the String, used to invoke this method.
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'}"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With