disable options in the List JSF 2

情到浓时终转凉″ 提交于 2019-12-11 08:21:26

问题


<h:selectManyListbox value="#{bean.selectedColor}">
            <f:selectItems value="#{bean.colors}" var="u"
            itemLabel="#{u.code}" itemValue="#{u.description}" itemDisabled="true"/>
        </h:selectManyListbox>

I set itemDisabled to true in f:selectItems but it is still enabled on the screen. Please let me know if I am missing anything.


回答1:


This generates a HTML <option disabled="true"> element. The specified behaviour is that the item is unselectable, not that the item is hidden. You seem to be expecting that the item is hidden. This is thus not true. If you don't want to show the item in the list at all, just prepare the #{bean.colors} list as such that the item is not present in the list.

See also:

  • <f:selectItems> tag documentation - read the itemDisabled attribute description
  • disabled attribute in W3 HTML specification - nothing states that it's hidden


来源:https://stackoverflow.com/questions/9899601/disable-options-in-the-list-jsf-2

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