Basically I am simply trying to add a <br> (or something equivalent) to the "value" attribute of a <p:commandButton> like this:
<p:commandButton value="#{aBean.text}" />
<!-- #{aBean.text} returns for example "text1<br>text2" -->
Sadly, there is no possibility to set escape="false". Trying to add a custom converter didn't work, either. I have, without success, also tried to do it like this:
<p:commandButton>
<h:outputText escape="false" value="#{aBean.text}" />
</p:commandButton>
In my opinion adding a simple line break should be easy enough, right? Does anyone have a solution for this?
You need to use which represents the XML entity reference for \n.
<p:commandButton value="text1 text2" style="white-space: pre;" />
The white-space: pre; is mandatory on <p:commandButton>, but not on <h:commandButton>, because the PrimeFaces one generates it as a <button type="submit"><span> instead of a <input type="submit">.
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