How can I put a line break to the PrimeFaces tooltip
component to separate the first line from the second line?
<p:tooltip id="toolTip"
for="idButton"
value="First line Second Line"
position="top"/>
To show the tooltip with a line break you have to put it like this
<p:tooltip for="...">
<h:outputText value="First line"/>
<br/>
<h:outputText value="Second line"/>
</p:tooltip>
Or using PrimeFaces Extensions (pe:tooltip)
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:pe="http://primefaces.org/ui/extensions">
...
<pe:tooltip for="...">
<h:outputText value="First line <br/> Second line" escape="false" />
</pe:tooltip>
https://forum.primefaces.org/viewtopic.php?t=23196
PrimeFaces tooltip supports the escape
attribute since 5.1, so just do
<p:tooltip id="toolTip"
for="idButton"
value="First line<br/> Second Line"
position="top"
escape="false"/>
But if you want to have a more 'visible' html, you can also do
<p:tooltip id="toolTip" for="idButton" position="top">
First line
<br/>
Second Line
</p:tooltip>
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