如何嵌入输入组件,例如一个 selectOneMenu 到一个 PickList?

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

当我将 value 属性放入 selectOneMenu value="#{customer.customerType}" 时出现以下错误:

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

选择列表:

<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>

豆子:

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

CustomerType 枚举:

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;
    }
}

选择列表通常不包含输入 'controls'。所以 p:pickList 从未被设计为包含像 h\p:selectonemenu 甚至普通的 h\p:inputTexts 这样的输入。所以它不像你期望的那样工作,这很不幸。重新设计您的 ui 是唯一可以做的事情。