OAF开发中的一些知识(转)

转自:http://blog.sina.com.cn/s/blog_6100b0a20101972s.html

OAF开发时总结的小知识点 :

1:变量类型之间的转换:

(1):int => 其他类型

Int xxxx;

Number yyyy = (Number)xxxx;

Number yyyy=new Number(xxxx);

String yyyy = String.valueOf(xxxx);

String yyyy = Integer.toString(xxxx);

String yyyy = ""+xxxx;

(2):number => 其他类型

Number xxxx;

Int yyyy = xxxx.intValue();

int yyyy = (int)xxxx;

String yyyy = ""+xxxx;

String yyyy =String.valueOf(xxxx);

(3):date => 其他类型

Date xxxx;

String yyyy= String.valueOf(xxxx);

String yyyy= xxxx.toString();

(4):String => 其他类型

String xxxx;

int yyyy = Integer.parseInt(xxxx);

int yyyy = Integer.valueOf(xxxx);

try {

Number yyyy = new Number(xxxx);

}

catch (Exception e) {

}

Number yyyy = (Number)xxxx;

Date yyyy = Date.valueOf(xxxx);

Date yyyy = (Date)xxxx;

2:OAF之间的一些基本的实现方法:

(1):一般在CO中不写具体的逻辑代码,要将所有的方法放到AM中 ,然后在CO中调用AM中的函数或者过程。具体的方法是:

OAApplicationModule am = pageContext.getApplicationModule(webBean);

调用过程: String useId = ""+useid;

Serializable[] parameters = { useId };

am.invokeMethod("init", parameters);

(am.invokeMethod("init");)

调用函数:String supplierid = Integer.toString(n);

Serializable[] param = {supplierid};

Serializable SupplierName = am.invokeMethod("GetSupplierName",param);

备注:SupplierName 可以直接使用,类型取决于函数返回的类型

3:页面上的变量或者项的获得和赋值方法:

(1):链接上传入的变量的值:

OA.jsp?page=/oracle/apps/xxpos/xxpos5961/back/webui/CreatePG&BackNumber={@BackNumber}&HeaderId={@HeaderId}&HeaderStatus={@HeaderStatus}&retainAM=Y&addBreadCrumb=Y&UpdateFlg=Y

String backnumber = pageContext.getParameter("BackNumber");

(2):得到页面上的item:

OAMessageLovInputBean asnBean1 = (OAMessageLovInputBean)webBean.findChildRecursive("NumberFromSearch");

String aa="";

asnBean1.setValue(pageContext,aa);

4:得到VO和当前行的方法:

OAViewObject voDetail = (OAViewObject)am.findViewObject("BackPVO1");

BackPVORowImpl rowDetail = (BackPVORowImpl)voDetail.getCurrentRow();

得到VO中某个字段的方法:

String N = ""+rowDetail.getUserTypeID();

或者:

Number headerid =

(Number) voDetail.getCurrentRow().getAttribute("HeaderId");

5:循环判断页面上的记录的方法:

//校验实收数量是否大于换货数量

OAViewObject voline = (OAViewObject)am.findViewObject("DetailLineVO1");

Row rowLine = voline.first();

int rec_record = 0;

while (rowLine != null) {

Number backquan =(Number)rowLine.getAttribute("BackQuantity");

Number actualquan =(Number)rowLine.getAttribute("ActualQuantity");

String TOsubinv = (String)rowLine.getAttribute("ToSubinventoryCode");

String TOlocator = ""+(Number)rowLine.getAttribute("ToLocatorId");

rec_record = rec_record +1;

String record_num = ""+ rec_record;

String ACTUALQUAN = ""+actualquan;

if (!(TOsubinv != null && TOsubinv.length() != 0)){

System.out.println("enter this 1111");

MessageToken[] errTokens = { new MessageToken("RECORD_NUM",record_num)};

throw new OAException("XXPOS","FWK_TBX_T_BACK_NO_TOLOTSUB",errTokens);

}

if ("null".equals(TOlocator)){

System.out.println("enter into here 2222");

MessageToken[] errTokens = { new MessageToken("RECORD_NUM",record_num)};

throw new OAException("XXPOS","FWK_TBX_T_BACK_NO_TOLOCATOR",errTokens);

}

if ("null".equals(ACTUALQUAN)){

System.out.println("enter into here 3333");

MessageToken[] errTokens = { new MessageToken("RECORD_NUM",record_num)}; throw new OAException("XXPOS","FWK_TBX_NO_ACTU_QUAN",errTokens);

}

else{

if (backquan.compareTo(actualquan)<0){

System.out.println("the actual is wrong");

MessageToken[] errTokens = { new MessageToken("RECORD_NUM",record_num)};

throw new OAException("XXPOS","FWK_TBX_T_ACTU_QUAN_BELOW",errTokens);

}

}

rowLine = voline.next();

}

6:AM中调用plsql包的方法是:

调用函数且返回值:

public String get_header_status(String headerid){

String result;

OADBTransaction adbtransaction = (OADBTransaction)getDBTransaction();

String s = "BEGIN :1:=xxpos_5961_back_process_pkg.get_header_status(p_header_id => :2); END;";

OracleCallableStatement raclecallablestatement = (OracleCallableStatement)oadbtransaction.createCallableStatement(s,1);

try

{

oraclecallablestatement.registerOutParameter(1,OracleTypes.VARCHAR);

oraclecallablestatement.setString(2,headerid);

oraclecallablestatement.execute();

result=oraclecallablestatement.getString(1);

}

catch(Exception exception1)

{

throw OAException.wrapperException(exception1);

}

finally

{

try

{

oraclecallablestatement.close();

}

catch(Exception _ex)

{

}

}

return result;

}

调用过程 :

public void setvaluesequence(String headerid)

{

System.out.println("set value sequence is 1111"+headerid);

OADBTransaction txn = getOADBTransaction();

CallableStatement cs =txn.createCallableStatement("begin xxpos_5961_back_process_pkg.seq_setvalue(p_header_id =>:1); end;",1);

try {

cs.setString(1,headerid);

cs.execute();

cs.close();

}

catch (SQLException sqle)

{

throw OAException.wrapperException(sqle);

}

}

调用函数不返回值:

public void delete_reserve()

{

OAViewObject voDetail = (OAViewObject)findViewObject("DetailHeaderVO1");

DetailHeaderVORowImpl rowDetail = (DetailHeaderVORowImpl)voDetail.getCurrentRow();

String headerid = ""+rowDetail.getHeaderId();

String result;

OADBTransaction adbtransaction = (OADBTransaction)getDBTransaction();

String s = "BEGIN :1:=xxpos_5961_back_process_pkg.delete_reserve(p_header_id => :2); END;";

OracleCallableStatement cs = (OracleCallableStatement)oadbtransaction.createCallableStatement(s,1);

try {

cs.registerOutParameter(1,OracleTypes.VARCHAR);

System.out.println("headerid si si sis wangshue"+headerid );

cs.setString(2,headerid);

cs.execute();

result=cs.getString(1);

}

catch(Exception exception1)

{

throw OAException.wrapperException(exception1);

}

finally

{

try

{

cs.close();

}

catch(Exception _ex)

{

}

}

if ("F".equals(result))

{

throw new OAException("XXPOS", "FWK_TBX_DELETE_RESERVE_FAILURE");

}

}

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

转载于:http://blog.itpub.net/24627116/viewspace-758670/

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值