OAF_开发系列07_实现OAF下拉菜单的上下联动Poplist Synchor(案例)

  1. 云栖社区>
  2. 博客>
  3. 正文

OAF_开发系列07_实现OAF下拉菜单的上下联动Poplist Synchor(案例)

东方瀚海鲍 2015-06-27 09:24:00 浏览1092
展开阅读全文

20150706 Created By BaoXinjian

一、摘要


下拉列表的级联显示是非常常用的一种界面显示效果,在FORMS中我常作,作法也很简单,可OAF中显然有点麻烦了

现假定有张表,里面有两个字段,一个是Province(省),一个是City(市)

现需要在页面上放置两个下拉列表字段,一个选择省,一个选择市,当然,选择市的下拉列表值需要根据省的下拉列表的选择进行筛选。

实现思路:

实际上很简单,与FORMS差不多,就是要动态的指定选择市的下拉列表的查询,当选择完省后,立即更新市的查询

在Form中通过Trigger进行下拉菜单变更事件的抓取

在OAF中通过Event进行下来菜单变更事件的抓取

 

二、实现分析


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/

ERP技术讨论群: 288307890
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建

网友评论

登录后评论
0/500
评论
东方瀚海鲍
+ 关注