ToolTip for each SelectOneMenu Items in jsf

爱⌒轻易说出口 提交于 2019-12-02 01:09:19

You can use javascript. Assume your selectOneMenu as below.

<h:form id="form1">
    <h:selectOneMenu id="combo1">
        <f:selectItem itemLabel="First Label"/>
        <f:selectItem itemLabel="Second Label"/>
        <f:selectItem itemLabel="Third Label"/>
    </h:selectOneMenu>
</h:form>

Add this script at the top of your page.

<script>
    window.onload = function() {
         var options = document.getElementById("form1:combo1").options;
         for(var i = 0; i &lt; options.length; i++) {
             options[i].title = options[i].innerHTML;
         }
    }
</script>

If you are using a list of "javax.faces.model.SelectItem" you can pass the description attribute to show a tooltip for each and every option.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!