Disabling items with PrimeFaces SelectOneMenu with custom content / p:column

一个人想着一个人 提交于 2019-12-12 00:08:00

问题


it seems as if it is not possible to disable items in a SelectOneMenu from PrimeFaces (3.3) when using the custom content (as shown at http://www.primefaces.org/showcase-labs/ui/selectOneMenu.jsf).

The testcase is simple, just take the following:

<h:form>
    <p:selectOneMenu value="#{testBean.selected}">
        <f:selectItems value="#{testBean.options}" var="t"
            itemLabel="#{t.label}" itemValue="#{t}"
            itemDisabled="#{t.value % 2 == 0 ? 'true' : 'false'}" />
    </p:selectOneMenu>

    <p:selectOneMenu value="#{testBean.selected}" var="x">
        <f:selectItems value="#{testBean.options}" var="t"
            itemLabel="#{t.label}" itemValue="#{t}"
            itemDisabled="#{t.value % 2 == 0 ? 'true' : 'false'}" />
        <p:column>
            #{x.label} -- #{x.label}
        </p:column>
    </p:selectOneMenu>
</h:form>

and the following Java files:

Bean:

@Named
public class TestBean {

private TestObject  selected;
// getter/setter

public List<TestObject> getOptions() {
    return Arrays.asList(new TestObject("1"), new TestObject("2")); }
}

Object:

public class TestObject {
    private Integer value;
    // getter/setter

    public TestObject() {}
    public TestObject(String s) {
        this.setLabel(s);
    }
    public String getLabel() {return "label: " + value;}
    public void setLabel(String l) {this.value = new Integer(l);}
}

The first dropdown works fine, the second one doesn't. Any idea on how to solve that?

来源:https://stackoverflow.com/questions/10817760/disabling-items-with-primefaces-selectonemenu-with-custom-content-pcolumn

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