Id (personBean.idSelectedItem) 始终返回 null。虽然我可以选择并更改下拉列表的值,但 Id 仍然为空,不会相应更改。请帮助我,以下是我的代码:
<h:selectOneMenu value="#{personBean.idSelectedItem}" immediate="true" onchange="EnableDisable()">
<f:selectItems value="#{personBean.apptDuration}" />
</h:selectOneMenu>
我的豆是:
private String idSelectedItem = null;
private List<SelectItem> apptDuration = null;
public String getIdSelectedItem() {
System.out.println("getIdSelectedItem == " + idSelectedItem);
return idSelectedItem;}
public void setIdSelectedItem(String idSelectedItem) {
this.idSelectedItem = idSelectedItem;
System.out.println("setIdSelectedItem == " + idSelectedItem);
}
public List<SelectItem> getApptDuration() {
if (apptDuration == null) {
apptDuration = new ArrayList<SelectItem>();
apptDuration.add(new SelectItem("P1", "Day(s)"));
apptDuration.add(new SelectItem("P2", "5 min"));
apptDuration.add(new SelectItem("P3", "10 min"));
apptDuration.add(new SelectItem("P4", "15 min"));
}
return apptDuration;
}
public void setApptDuration(List<SelectItem> apptDuration) {
this.apptDuration = apptDuration;
}
我的代码有什么问题?