3

I am using t:selectItem inside a s:selectOneMenu. My itemLabel are too long to be seen inside the selectOneMenu window. Does anyone know, how to get a tooltip for each selectItem? Appreciate any ideas in this direction.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
ANIL
  • 206
  • 1
  • 8

1 Answers1

1

You can use javascript for this. Since you haven't provided any code sample I use following sample. You may catch the concept and apply it for your requirement accordingly.

<h:form id="myForm">
    <h:selectOneMenu id="myCombo">
        <f:selectItem itemLabel="Label1"/>
        <f:selectItem itemLabel="Label2"/>
        <f:selectItem itemLabel="Label3"/>
    </h:selectOneMenu>
</h:form>

your javascript code should be as below.

<script>
    window.onload = function(){
         var options = document.getElementById("myForm:myCombo").options;
         for(var i = 0; i &lt; options.length; i++) {
             options[i].title = options[i].innerHTML;
         }
    }
</script>
prageeth
  • 7,159
  • 7
  • 44
  • 72
  • Thanks for your help man..but it also not working...any other suggestion please??? – ANIL Jan 07 '13 at 09:51
  • – ANIL Jan 07 '13 at 11:09