Search code examples
jsfprimefaces

How to add text on mouse hover for p:toggleSwitch


I am trying to add some text while tuning on/off the p:toggleSwitch.

<p:toggleSwitch showTooltip="true"  
title="Enable/Disable Property"  
id="d_enable" onLabel="On" offLabel="Off"   
value="#{mybean.dEnabled}" />

I tried that but it's are not working.


Solution

  • You cannot do that using the ToggleSwitch component. Instead, combine it with a ToolTip component like:

    <p:toggleSwitch id="myToggleSwitch" .../>
    <p:tooltip for="myToggleSwitch" value="My toggleSwitch tip"/>
    

    And, instead of guessing attributes, consider using an IDE which can assist you in using existing attributes, or simply read the ToggleSwitch documentation.