How do I embed an input component like e.g. a selectOneMenu into a PickList?

☆樱花仙子☆ 提交于 2019-12-11 13:16:14

问题


I am getting the following error when I put the value attribute in the selectOneMenu value="#{customer.customerType}":

javax.el.PropertyNotFoundException: Target Unreachable, identifier 'customer' resolved to null

PickList:

<p:pickList id="customersPL" itemLabel="#{customer.id}"
    itemValue="#{customer}" responsive="true"
    value="#{bean.customersList}" var="customer">

    <o:converter converterId="omnifaces.ListConverter"
        list="#{bean.customersListSource}" />

    <p:ajax event="transfer" listener="#{bean.onTransfer}" />

    <p:column>
        <h:outputText value="#{customer.name}" />
    </p:column>

    <p:column>
        <p:selectOneMenu converter="omnifaces.SelectItemsConverter"
            id="customerType" value="#{customer.customerType}">
            <f:selectItems itemLabel="#{customerType.name}"
                itemValue="#{customerType}"
                value="#{bean.customerTypesList}"
                var="customerType" />
        </p:selectOneMenu>
    </p:column>
</p:pickList>

Bean:

private CustomerType[] customerTypesList = CustomerType.values();

CustomerType Enum:

public static enum CustomerType {
    WHOLESALE("W", "Wholesale"), RETAIL("R", "Retail");

    private String id;
    private String name;

    TipoCliente(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }
}

回答1:


Picklists in general are not intended to contain input 'controls'. So the p:pickList was never designed to contain inputs like h\p:selectonemenu or even plain h\p:inputTexts. So it does not work like you expect it to and that is just unfortunate. Redesigning your ui is the only thing to do.



来源:https://stackoverflow.com/questions/32489834/how-do-i-embed-an-input-component-like-e-g-a-selectonemenu-into-a-picklist

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