简体   繁体   中英

How do I put line break in p:tooltip

如何在tooltip primefaces组件上primefaces以将第一行与第二行分开?

<p:tooltip id="toolTip" for="idButton" value="First line Second Line" position="top"/>

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM