问题
<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
itemDisabledattribute 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