ViewScope bean 是否允许 ajax 调用?
例如:
这是一个xhtml页面:
<h:body>
<h:selectOneMenu value="#{test.selected}">
<f:selectItem itemValue="2" itemLabel="2" />
<f:selectItem itemValue="3" itemLabel="3" />
<f:ajax listener="#{test.updateData()}" />
</h:selectOneMenu>
</h:body>
这是 ViewScoped Bean:
@ViewScoped
@Named
public class test implements Serializable{
private String selected;
public void updateData(){
System.out.println("Ajax call successful.");
}
public String getSelected() {
return selected;
}
public void setTest(String test) {
this.selected = selected;
}
}
当我尝试这个时,它没有用。