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