update=":theShowPage"表示切换完按钮后更新的页面。
后台页面:
public void userTypeChange(AjaxBehaviorEvent event) { Object item = ((SelectOneMenu) event.getSource()).getSubmittedValue(); int role= Integer.parseInt((String.valueOf(item))); if (newValue == "管理员") { user.setUserType(1); } }前台页面如果要显示不同的值,可以在同一个页面上用rendered属性,这种验证能通过int型或boolean类型进行显示,String类型的不行例如:
rendered="#{userBean.user.userType==1}" 详细的一种写法: bean页面: private String province; private String city; public String getProvince() { return province; } public void setProvince(String province) { this.province = province; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } List selectItemList = new ArrayList(); public List getSelectItemList() { return selectItemList; } public void changeProvince(AjaxBehaviorEvent event) { String selectedValue =String.valueOf(((HtmlSelectOneMenu)event.getSource()).getSubmittedValue()) ; if (selectedValue.equals("hbs")) { selectItemList.add(new SelectItem("2", "Label2")); } else { selectItemList.add(new SelectItem("1", "Label1")); } }