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/