我使用select one菜单从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
当我将fieldset放入表单时它不会设置任何内容
提前致谢
我发现问题了
通过添加ajax
,问题将解决
<p:ajax event="change" update="@this" />