a4j实现联动菜单(异步)
来源:互联网 发布:5s如何设置4g网络 编辑:程序博客网 时间:2024/04/29 14:05
a4j实现联动菜单(异步)
JSF页面:
<h:selectOneMenu id="country" value="#{countryCity.country}">
<f:selectItems value="#{countryCity.countryName}"/>
<a4j:support event="onchange" reRender="city" action="#{countryCity.change}"/>
</h:selectOneMenu>
<h:selectOneMenu id="city">
<f:selectItems value="#{countryCity.currentCityName}"/>
</h:selectOneMenu>
backingbean:
public class CountryCity {
private List<SelectItem> countryName;
private List<List<SelectItem>> cityName;
private List<SelectItem> currentCityName;
private String country;
public CountryCity(){
countryName = new ArrayList();
countryName.add(new SelectItem("0","China"));
countryName.add(new SelectItem("1","England"));
countryName.add(new SelectItem("2","America"));
List<SelectItem> china = new ArrayList();
china.add(new SelectItem("guangzhou","guangzhou"));
china.add(new SelectItem("xianggang","xianggang"));
List<SelectItem> england = new ArrayList();
england.add(new SelectItem("Londun","Londun"));
List<SelectItem> america = new ArrayList();
america.add(new SelectItem("housdun","housdun"));
america.add(new SelectItem("Washdom","Washdom"));
cityName = new ArrayList();
cityName.add(china);
cityName.add(england);
cityName.add(america);
currentCityName = cityName.get(0);
}
public List<SelectItem> getCountryName() {
return countryName;
}
public void setCountryName(List<SelectItem> countryName) {
this.countryName = countryName;
}
public List<List<SelectItem>> getCityName() {
return cityName;
}
public void setCityName(List<List<SelectItem>> cityName) {
this.cityName = cityName;
}
public List<SelectItem> getCurrentCityName() {
return currentCityName;
}
public void setCurrentCityName(List<SelectItem> currentCityName) {
this.currentCityName = currentCityName;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public void change(){
currentCityName = cityName.get(Integer.parseInt(getCountry()));
}
}
faces-config.xml声明:
<managed-bean>
<managed-bean-name>countryCity</managed-bean-name>
<managed-bean-class>bb.CountryCity</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
范围应该设成session,不然会出现bug。
JSF实现联动菜单(同步):
http://hi.baidu.com/coolcat%5Fpolice/blog/item/77b6013dcf4909c29e3d622f.html
- a4j实现联动菜单(异步)
- 实现三级联动菜单(ajax)
- javascript实现联动菜单
- 实现联动菜单
- 实现联动菜单
- easyui tree异步树菜单联动
- 简单二级联动菜单实现
- Ajax实现二级联动菜单
- struts2实现二级菜单联动
- Ajax+jQuery 实现菜单联动
- Ajax实现二级联动菜单
- Ajax实现二级联动菜单
- Excel实现菜单联动功能
- Ajax实现多级联动菜单
- select 联动菜单实现代码
- Ajax实现二级联动菜单
- Ajax实现二级联动菜单
- Jquery实现菜单联动效果
- 在android的java代码中自定义log
- 深入探讨 Java 类加载器
- poj 3692
- OpenCV实现图像的旋转
- 简单模板类
- a4j实现联动菜单(异步)
- struct nand_ecclayout 之解义 ,eccbytes,eccpos,eccfree
- PCB阻抗控制
- SVM支持向量机(Support Vector Machine)-翻译版
- 1003. Erdős Number
- 复杂地思考 think complexity
- 【云雾山&&风景xp主题】_rmzt
- 使用sudo时user is not in sudoers file 的解决
- 两个子数组有序,融合后依然有序