【问题标题】:JSF Trinidad selectOneChoice UI COmponentJSF 特立尼达 selectOneChoice UI 组件
【发布时间】:2012-10-09 02:18:52
【问题描述】:

这是我的 .xhtml 文件

<tr:selectOneChoice >
   <f:selectItems value="#{bean.items}"/>
</tr:selectOneChoice>

我希望能够识别客户端的不同选项。 在我的支持 bean 中,每个选项都有布尔值。

是否可以在客户端实际识别这些选项?

bean 代码是这样的:

public List<SelectItem> getItems(Menu menu) {
    List<SelectItem> list = new ArrayList();
    SelectItem selectItem = new SelectItem(new MyObj("some string",false), "label");
    list.add(selectItem);
    return list;
}

MyObj 类包含我希望能够在客户端看到的标志。

有人知道怎么做吗?

谢谢,

约翰。

【问题讨论】:

    标签: java jsf trinidad


    【解决方案1】:

    您为什么不直接创建MyObj 的List,遍历列表并使用f:selectItem 上的itemDisabled 属性。

    <tr:selectOneChoice>
      <tr:forEach items="#{bean.myObjList}" var="myObj">
        <f:selectItem itemLabel="#{myObj.label}"
                      itemValue="#{myObj.value}"
                      itemDisabled="#{myObj.flag}"/>
      </tr:forEach>
    </tr:selectOneChoice>
    

    【讨论】:

    • 我不想要禁用的项目。我只是希望某些项目将包含来自服务器的一些布尔值,并且我将能够在客户端上看到它->然后当用户单击一个项目时-我希望客户端能够从事件中获取这也触发了这个布尔值,所以我可以检查项目是否为“真”并做一些事情..
    • 你不能只使用值更改侦听器来做到这一点吗?
    猜你喜欢
    • 2011-08-13
    • 2012-12-07
    • 2012-08-09
    • 2011-08-03
    • 2011-10-24
    • 2012-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多