禁用列表JSF 2中的选项 [英] disable options in the List JSF 2

查看:59
本文介绍了禁用列表JSF 2中的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我在f:selectItems中将itemDisabled设置为true,但它仍在屏幕上启用.请让我知道我是否有任何遗漏.

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.

推荐答案

这将生成HTML <option disabled="true">元素.指定的行为是该项目是不可选择的,而不是该项目是隐藏的.您似乎期望该项目被隐藏.因此,这是不正确的.如果您根本不想在列表中显示该项目,则只需准备#{bean.colors}列表,这样该项目就不会出现在列表中.

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.

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

这篇关于禁用列表JSF 2中的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆