我正在尝试为下拉列表添加ajax,我在xhtml中添加了以下代码,但是一旦发生更改,就不会调用listner。
XHTML代码:
<h:selectOneMenu
value="#{loginBean.dropDownValue}" itemValue="#{dropDownValue}">
<f:selectItem itemValue="****select***" />
<f:selectItems value="#{loginBean.testDropDown}"/>
<f:ajax event="change" listner="#{loginBean.changeDropDownOne}" render="testDropDownTwoValue" />
</h:selectOneMenu>
bean中的方法:
public List<SelectItem> changeDropDownOne() {
System.out.println("$$$$$$$$$$");
String dp = getDropDownValue();
if(dp != null) {
System.out.println("**********************getTestDropDownTwo********************************"+dp);
if(dp.equalsIgnoreCase("One")) {
testDropDownTwo.add(new SelectItem("One - One"));
testDropDownTwo.add(new SelectItem("One - Two"));
testDropDownTwo.add(new SelectItem("One - Three"));
testDropDownTwo.add(new SelectItem("One - Four"));
} else if(dp.equalsIgnoreCase("Two")) {
testDropDownTwo.add(new SelectItem("Two - One"));
testDropDownTwo.add(new SelectItem("Two - Two"));
testDropDownTwo.add(new SelectItem("Two - Three"));
testDropDownTwo.add(new SelectItem("Two - Four"));
}else if(dp.equalsIgnoreCase("Two")) {
testDropDownTwo.add(new SelectItem("Three - One"));
testDropDownTwo.add(new SelectItem("Three - Two"));
testDropDownTwo.add(new SelectItem("Three - Three"));
testDropDownTwo.add(new SelectItem("Three - Four"));
}else {
testDropDownTwo.add(new SelectItem("Four - One"));
testDropDownTwo.add(new SelectItem("Four - Two"));
testDropDownTwo.add(new SelectItem("Four - Three"));
testDropDownTwo.add(new SelectItem("Four - Four"));
}
}
return testDropDownTwo;
}