OAF 中怎样设置动态的查询

在OAF的开发中,动态查询是避免不了的,就是根据用户输入的条件来查询,当然OAF中有很多方面的方法,但是有一种方法是用的最为普遍的.

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

am.invokeMethod("initDetails", parameters);

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

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

2.在AM的java文件中写一个initDetails方法函数,来调用VO中的方法.如:initQuery(String XXXX);

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

这段代码直接运行的话要原来的基础上要import一个类:

import java.util.Vector

Initialize and execute the query
public void initQuery(String name, String onHold, String number)
{

StringBuffer whereClause = new StringBuffer(100);
Vector parameters = new Vector(3);
int clauseCount = 0;
int bindCount = 0;

setWhereClauseParams(null); // Always reset

   if ((name != null) && (!("".equals(name.trim()))))
   {
     whereClause.append(" NAME like :");
     whereClause.append(++bindCount);
     parameters.addElement(name + "%");
     clauseCount++;
   }
   if ((number != null) && (!(""Equals(number.trim()))))
   {
   
     Number supplierId = null;
   
     // SUPPLIER_ID is a NUMBER; datatypes should always
     // match, and the parameter passed to this method is a
     // String.
     try
     {
       supplierId = new Number(number);
     } 
     catch(Exception e) {}
   
     if (clauseCount > 0)
     {
       whereClause.append(" AND "); 
     }
   
     whereClause.append(" SUPPLIER_ID = :");
     whereClause.append(++bindCount);
     parameters.addElement(supplierId);
     clauseCount++;
   }
   if ((onHold != null) && (!(""Equals(onHold.trim()))))
   {
     if (clauseCount > 0)
     {
       whereClause.append(" AND "); 
     }
   
     whereClause.append(" ON_HOLD_FLAG = :");
     whereClause.append(++bindCount);
     parameters.addElement("Y"); 
     clauseCount++;
   }
   setWhereClause(whereClause.toString());
   if (bindCount > 0) 
   {
     Object[] params = new Object[bindCount];
   
     // the copyInto() is 1.1.8 compliant which, as of 4/02/03, is required by ARU
   
     parameters.copyInto(params); 
     setWhereClauseParams(params);
  }
   
  executeQuery();
 } // end initQuery( )
 
 
 
 
Genterate an Application Module Interface

If you want to generate an application module interface

so you can invoke typed methods directly

(with compile-time checking) instead of calling

invokeMethod(), you must first create the methods

that you want to expose to the client. Then:

  1. In the JDeveloper Navigator, select the application module
  2. that you just created, right-click and select Edit <appmodule_name>....
  3. In the Application Module Wizard, select Client Methods.
  4. Select the methods you want to be able to invoke remotely in the
  5. Available list and shuttle them to the Selected list.
  6. Select OK to create your interface.
[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7200614/viewspace-982530/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7200614/viewspace-982530/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值