John Alexander Betts
John Alexander Betts

Reputation: 5206

Render a tooltip if an error validation message exists

If I have this tooltip:

<p:tooltip for="code" hideEffect="fade" showEffect="fade" >
    <p:message for="code" />
</p:tooltip>

How can I do to show the tooltip box only if exists an error validation message?

Currently my tooltip looks like this:

enter image description here

Upvotes: 2

Views: 4677

Answers (2)

Babl
Babl

Reputation: 7646

If anyone still needs this. This works with JSF 2.2 PF 5.0

<p:tooltip id="toolTipContent" for="code" trackMouse="true" 
  rendered="#{not empty facesContext.messageList and not empty facesContext.getMessageList('form:code')}">
    <p:message for="code" />    </p:tooltip>

Upvotes: 4

lefloh
lefloh

Reputation: 10961

Add a rendered Attribute and check if there is an error-message for this element:

rendered="#{not empty facesContext.getMessageList('code')}"

Upvotes: 0

Related Questions