OAF_开发系列13_实现OAF通过Vector动态查询设置(案例)

简介: 20150715 Created By BaoXinjian 一、摘要 Oracle OAF Guide上介绍的标准客制化查询的方式,在多条件下进行查询 具体实现步骤如下 Step1.在controler中的processRequest 的方法中调用 (1).

20150715 Created By BaoXinjian

一、摘要


Oracle OAF Guide上介绍的标准客制化查询的方式,在多条件下进行查询

具体实现步骤如下

Step1.在controler中的processRequest 的方法中调用

(1). am.invokeMethod("vectorQuery", parameters);

(2). 当然要调用invokeMethod方法先要 OAApplicationModule am = pageContext.getApplicationModule(webBean) 来实例化am;、;

(3). initDetails是写在AM的java 文件的中的一个方法,parameters可以用pageContext.getParameters 方法得到你想要的任何参数;

Step2. 在AM的java文件中写一个vectorQuery方法函数,来调用VO中的方法。

Step3. 在VO中添加下面的代码,这个代码是从OAF的UG里面拿出来的,我觉得这段代码比较的经典,以后在开发中会不断的用到;

 

二、实现方式


1.  创建查询页面如下,新增按钮SearchEmployee,并触发时间Search

 

2. 在CO中新增方法,获取Search时间,并调换用AM中的实现方法

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    
    if ("Search".equals(pageContext.getParameter(EVENT_PARAM))) {
        String p_employee_num = pageContext.getParameter("EmployeeNumQ");
        String p_employee_name = pageContext.getParameter("EmployeeNameQ");
        String p_employee_country = pageContext.getParameter("EmployeeCountryQ");
        Serializable[] params = {p_employee_num, p_employee_name, p_employee_country};
        OAApplicationModule am = pageContext.getApplicationModule(webBean);
        am.invokeMethod("vectorQuery",params);
    }  
}

 

3.  在AM中创建实现方法,最为关键的一步

public void vectorQuery(String p_employee_num, String p_employee_name, String p_employee_country) {
   
   //VO初始化
   EmployeesVOImpl employeevo = this.getEmployeesSearchVO();
   
   //参数初始化
   StringBuffer whereClause = new StringBuffer(100);
   Vector parameters = new Vector(3);
   int clauseCount = 0;
   int bindCount = 0;
   
   //加入第1个条件Employee Num
   if ((p_employee_num != null) && (!("".equals(p_employee_num.trim()))))
   {
     whereClause.append(" EMPLOYEE_NUM like :");
     whereClause.append(++bindCount);
     parameters.addElement("%" + p_employee_num + "%");
     clauseCount++;
   }
   
   //加入第2个条件Employee Name
   if ((p_employee_name != null) && (!("".equals(p_employee_name.trim()))))
   {
     if (clauseCount > 0) {
       whereClause.append(" AND ");
     }
     whereClause.append(" EMPLOYEE_NAME like :");
     whereClause.append(++bindCount);
     parameters.addElement( "%" + p_employee_name + "%");
     clauseCount++;
   }
   
   //加入第3个条件Employee Country
   if ((p_employee_country != null) && (!("".equals(p_employee_country.trim()))))
   {
     if (clauseCount > 0) {
       whereClause.append(" AND ");
     }
     whereClause.append(" EMPLOYEE_COUNTRY like :");
     whereClause.append(++bindCount);
     parameters.addElement("%" + p_employee_country + "%");
     clauseCount++;
   }
   
   //VO查询WhereCause和Parameters赋值
   employeevo.setWhereClause(whereClause.toString());
   if (bindCount > 0) {
     Object[] params = new Object[bindCount];
     parameters.copyInto(params);
     employeevo.setWhereClauseParams(params);
   }
 
   //进行查询
   employeevo.executeQuery();

}

 

三、测试运行


Test1. 打开测试页面

 

Test2. 进行查询,资料顺利查出

 

Thanks and Regards

参考:http://shaofeng.blog.51cto.com/3392077/655682

ERP技术讨论群: 288307890
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建
相关文章
|
JavaScript
VUE element-ui之table表格全局排序、调用后端接口排序功能
VUE element-ui之table表格全局排序、调用后端接口排序功能
1526 0
|
存储 缓存 NoSQL
180729-Quick-Task 动态脚本支持框架之任务动态加载
前面几篇博文分别介绍了整个项目的基本架构,使用说明,以及整体框架的设计与实现初稿,接下来则进入更细节的实现篇,将整个工程中核心实现捞出来,从为什么这么设计到最终的实现给予说明
150 0
|
Oracle 关系型数据库
OAF_开发系列20_实现OAF打印功能
ddddd   添加一个页面级的button区域:pagebuttonBar,在之下添加button item ,这里主要设置的参数有:采用默认的oaf的打印按钮的id名称: IcxPrintablePageButton,设置属性集为:/oracle/apps/fnd/attributesets...
1198 0
|
关系型数据库 Oracle
OAF_开发系列14_实现OAF代码动态新增控件
dERP技术讨论群: 288307890 技术交流,技术讨论,欢迎加入 Technology Blog Created By Oracle ERP - 鲍新建
1140 0
|
SQL Oracle 关系型数据库
OAF_开发系列10_实现OAF动态LOV设定
20150712 Created By BaoXinjian 一、摘要 要在OAF中动态创建LOV的功能是很复杂的一件事,本文所讲述的动态LOV创建场合用于事先不能知道页面上会有多少个LOV,而且LOV所使用的SQL查询,也是由用户交互而获得的。
937 0
|
数据安全/隐私保护
OAF_开发系列12_实现OAF开发中URL中的标记和加密参数传递(案例)
20150712 Created By BaoXinjian 一、摘要 1. 标记 当你在声明式的页面定义中指定URL参数时,你可以直接指定文本也可以指定替代值的标记,这些标记在生成时会从控件所关联的VO对象属性中获取值(这也就是说,这些控件必须绑定到一个VO对象上)。
1147 0