Search code examples
jsftooltipnewline

Put linebreak/newline in tooltip


I'd like to put a linebreak in a tooltip so that it displays like:

Nom: value1
Quality: value2

I tried:

1.

<h:outputText title="Nom: #{cntc.value1}&lt;br/&gt;Quality: #{cntc.value1}" />

2.

<h:outputText title="Nom: #{ (''.concat(cntc.value1).concat('&lt;br/&gt;')concat('Quality: ').concat(cntc.value2)}" />

None of them worked for me. It seems that the <br/> isn't being interpreted.

How can I achieve this?


Solution

  • It's not a good idea to name the problem "Concatenating strings in EL" if your issue is with neither of those things. You want to create a multi-line title, that's an HTML problem.

    Title only accepts text so <br/> will not work but you can put a line break (&#13;) in there:

    <h:outputText value="#{cntc.mail }" title="Nom: #{cntc.nom}&#13;Qualite: #{cntc.qualite}" />
    

    Note that this may not work in every browser.