本文介绍了如何嵌入输入组件,例如将selectOneMenu放入PickList?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将value属性放在selectOneMenu value="#{customer.customerType}"
中时,出现以下错误:
I am getting the following error when I put the value attribute in the selectOneMenu value="#{customer.customerType}"
:
选择列表:
<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枚举:
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;
}
}
推荐答案
选择列表通常不打算包含输入控件".因此,p:pickList
从未被设计为包含h\p:selectonemenu
甚至普通的h\p:inputTexts
之类的输入.因此,它并不像您期望的那样工作,这只是不幸的.重新设计用户界面是唯一要做的事情.
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.
这篇关于如何嵌入输入组件,例如将selectOneMenu放入PickList?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!