【发布时间】:2015-07-28 10:16:15
【问题描述】:
我正在使用选择一个菜单从map<String,Integer> 中进行选择,但它只选择0:
<p:fieldset id="locations" legend="locations" toggleable="false">
<p:selectOneMenu id="locations" value="#{bean.selectedLocation}" filter="true" filterMatchMode="contains">
<f:selectItems value="#{bean.availableLocations}"/>
</p:selectOneMenu>
</p:fieldset>
我的豆子是:
@ManagedBean
@ViewScoped
public class Bean {
private Map<String, Integer> availableLocations = new HashMap<>();
private int selectedLocation = 1;
public int getSelectedLocation() {
return selectedLocation;
}
public void setSelectedLocation(int selectedLocation) {
this.selectedLocation=selectedLocation;
}
@Override
protected void init() {
availableLocations.clear();
availableLocations.putAll(Locations.getLocations());
}
}
当我选择任何项目时,它只是将0 设置为selectedLocation
当我将我的字段集放入表单时,它从未设置任何内容
提前致谢,
【问题讨论】:
-
要排除一个和另一个,如果在菜单组件上设置
converter="javax.faces.Integer"会怎样? -
谢谢@BalusC,不,它不起作用
标签: jsf jsf-2 primefaces hashmap selectonemenu