20150706 Created By BaoXinjianweb
1、摘要数据库
下拉列表的级联显示是很是经常使用的一种界面显示效果,在FORMS中我常做,做法也很简单,可OAF中显然有点麻烦了oracle
现假定有张表,里面有两个字段,一个是Province(省),一个是City(市)app
现须要在页面上放置两个下拉列表字段,一个选择省,一个选择市,固然,选择市的下拉列表值须要根据省的下拉列表的选择进行筛选。测试
实现思路:this
实际上很简单,与FORMS差很少,就是要动态的指定选择市的下拉列表的查询,当选择完省后,当即更新市的查询spa
在Form中经过Trigger进行下拉菜单变动事件的抓取.net
在OAF中经过Event进行下来菜单变动事件的抓取code
2、实现分析orm
Step1. 建立数据库资料, 省和市的资料
Step2. 新建一个Business Component Package(For AM and VO)
Step2.1 新建BC:
Package Name: bxj.oracle.apps.ap.poplist.server
Step2.2 新建AM:
AM Name: poplistAM
AM Path: bxj.oracle.apps.ap.poplist.server
Step2.3 新建省的VO(基于SQL):
VO Name: ChinaProvinceVO
VO Path: bxj.oracle.apps.ap.poplist.server
SQL: SELECT id, provinceid, province FROM bxj_province
Step2.4 新建市的VO(基于SQL):
VO Name: ChinaCityVO
VO Path: bxj.oracle.apps.ap.server
SQL: SELECT id, cityid, city, father FROM bxj_city
Step2.5 新建市的VO(基于SQL):
VO Name: ChinaAreaVO
VO Path: bxj.oracle.apps.ap.server
SQL: SELECT id, areaid, area, father FROM bxj_area
Step3. 联AM与VO(方法略)
Step4.新建Web Page 及Item
Step4.1新建Page
Step4.2 新建Item
Step5. 建立AM和CO方法
Step5.1 建立CO控制方法
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule empAM = pageContext.getApplicationModule(webBean); //当选择省时,刷新市
if ("refProvince".equals(pageContext.getParameter(EVENT_PARAM))) { String province = pageContext.getParameter("ChinaProvinceList"); String city = pageContext.getParameter("ChinaCityList"); String area = pageContext.getParameter("ChinaAreaList"); Serializable[] amprovinceparams = { province }; Serializable[] amaddressparams = { province, city, area }; empAM.invokeMethod("initCityAddress", amprovinceparams); empAM.invokeMethod("initAddress", amaddressparams); } //当选择市时,刷新县
if ("refCity".equals(pageContext.getParameter(EVENT_PARAM))) { String province = pageContext.getParameter("ChinaProvinceList"); String city = pageContext.getParameter("ChinaCityList"); String area = pageContext.getParameter("ChinaAreaList"); Serializable[] amcityparams = { city }; Serializable[] amaddressparams = { province, city, area }; empAM.invokeMethod("initAreaAddress", amcityparams); empAM.invokeMethod("initAddress", amaddressparams); } //当刷新写时,将省市县资料放到EmployeeAddress栏位中,完成自动赋值
if ("refArea".equals(pageContext.getParameter(EVENT_PARAM))) { String province = pageContext.getParameter("ChinaProvinceList"); String city = pageContext.getParameter("ChinaCityList"); String area = pageContext.getParameter("ChinaAreaList"); Serializable[] amaddressparams = { province, city, area }; empAM.invokeMethod("initAddress", amaddressparams); } }
Step5.2 建立AM实现方法
//当刷新省时,变动市VO的条件
public void initCityAddress(String p_province) { poplistAMImpl addressAM = (poplistAMImpl) this.getpoplistAMSearch(); ChinaCityVOImpl chinacityVO = addressAM.getChinaCityVO(); chinacityVO.setWhereClause(" province = :1 "); chinacityVO.setWhereClauseParam(0, p_province); chinacityVO.executeQuery(); } //当刷新市时,变动县VO的条件
public void initAreaAddress(String p_city) { poplistAMImpl addressAM = (poplistAMImpl) this.getpoplistAMSearch(); ChinaCityVOImpl chinacityVO = addressAM.getChinaCityVO(); chinacityVO.setWhereClause(" city = :1 "); chinacityVO.setWhereClauseParam(0, p_city); chinacityVO.executeQuery(); } //当刷新省市县时,自动赋值Address的值
public void initAddress(String p_province, String p_cit, String p_area) { EmployeesVOImpl employeeVO = this.getEmployeesCreateVO(); EmployeesVORowImpl employeeRow = (EmployeesVORowImpl) employeeVO.getCurrentRow(); employeeRow.setEmployeeAddress(p_province + p_cit + p_area); }
Step6 测试三个下拉菜单的级联,和对Address的自动赋值
Thanks and Regards
参考: Tony Liu - http://blog.itpub.net/10359218/viewspace-677454/