OAF_开发系列13_实现OAF通过Vector动态查询设置(案例)
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 - 鲍新建
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建
标签:
OAF
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?