我使用的選擇一個菜單從map<String,Integer>
選擇,但它只是選擇0
:JSF選擇一個菜單設置錯誤
<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
謝謝@BalusC,不,它不工作 –