Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a line break inside <p:commandButton />

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?

like image 735
Max Power Avatar asked Feb 14 '12 00:02

Max Power


Video Answer


1 Answers

You need to use &#10; which represents the XML entity reference for \n.

<p:commandButton value="text1&#10;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">.

like image 127
BalusC Avatar answered Oct 25 '22 23:10

BalusC