OAF_OAF增删改-修改的实现(案例)
2014-06-02 Created By BaoXinjian
一、摘要
实现OAF修改功能Update
二、案例
需求:实现修改功能
1. 建立Update按钮的连接
2. 设定触发事件为FireAction
3. 在SearchInvoiceCO.java中添加如下方法
4. 建立UpdateInvoicePG
5. 在UpdateInvoiceCO.java中添加如下方法
6. 在InvoiceAM中添加如下方法
7. 在InvocieUpdateVO中添加如下方法
8. 在UpdateInvoiceCO.java中添加如下方法
9. 在InvoiceAM中添加如下方法
三、案例实现
1. 建立Update的连接
2. 设定触发事件为FireAction
3. 在SearchInvoiceCO.java中添加如下方法
1 public void processFormRequest(OAPageContext pageContext,OAWebBean webBean) {
2
3 super.processFormRequest(pageContext, webBean);
4
5 /**按下更改发票Button,触发AM中的AmUpdateInvocie方法**/
6
7 if ("update".equals(pageContext.getParameter(EVENT_PARAM))) {
8
9 OAApplicationModule am = pageContext.getApplicationModule(webBean);
10
11 pageContext.setForwardURL("OA.jsp?page=/oracle/apps/bxj/ap/invoice/webui/UpdateInvoicePG",
12
13 null,
14
15 OAWebBeanConstants.KEEP_MENU_CONTEXT,
16
17 null,
18
19 null,
20
21 true,
22
23 OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
24
25 OAWebBeanConstants.IGNORE_MESSAGES);
26
27 }
28
29 }
4. 建立UpdateInvoicePG
5. 在UpdateInvoiceCO.java中添加如下方法
1 public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
2
3 super.processRequest(pageContext, webBean);
4
5 /**从SearchInvoice调转至UpdateInvoice,对修改发票页面初始化**/
6
7 String InvoiceId = pageContext.getParameter("InvoiceId");
8
9 if (!pageContext.isBackNavigationFired(false)) {
10
11 TransactionUnitHelper.startTransactionUnit(pageContext,"UpdateInvoiceTxn");
12
13 if (!pageContext.isFormSubmission()) {
14
15 Serializable[] params = { InvoiceId };
16
17 OAApplicationModule am = pageContext.getApplicationModule(webBean);
18
19 am.invokeMethod("AmInitUpdateInvoice",params);
20
21 }
22
23 } else {
24
25 if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"UpdateInvoiceTxn",true)) {
26
27 OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR);
28
29 pageContext.redirectToDialogPage(dialogPage);
30
31 }
32
33 }
34
35 }
6. 在InvoiceAM中添加如下方法
1 /**显示Invoice 明细页面**/
2
3 public void AmShowInvoice(String InvoiceId){
4
5 InvoiceDetailVOImpl vo = getInvoiceDetailVO1();
6
7 if (vo == null) {
8
9 MessageToken[] errtokens = {new MessageToken("OBJECT_NAME","InvoiceDetailVO1")};
10
11 throw new OAException("AK","FWK_TBX_OBJECT_NOT_FOUND",errtokens);
12
13 }
14
15 vo.VoShowInvoice(InvoiceId);
16
17 }
7. 在InvocieUpdateVO中添加如下方法
1 /**从SearchInvoice页面跳转至UpdateInvoice页面,实现自动查询**/
2
3 public void VoShowInvoice(String InvoiceId) {
4
5 if ((InvoiceId != null) & (!("".equals(InvoiceId.trim())))) {
6
7 Number Invoice_Id = null;
8
9 try {
10
11 Invoice_Id = new Number(InvoiceId);
12
13 } catch (Exception e) {
14
15 throw new OAException("CUX", "CUX_INVOICE_INVALID_NOTIFY_ID");
16
17 }
18
19 setWhereClause("INVOICE_ID = :1");
20
21 setWhereClauseParams(null);
22
23 setWhereClauseParam(0, Invoice_Id);
24
25 executeQuery();
26
27 }
28
29 }
8. 在UpdateInvoiceCO.java中添加如下方法
1 public void processFormRequest(OAPageContext pageContext,OAWebBean webBean) {
2
3 super.processFormRequest(pageContext, webBean);
4
5 /**按下确定Button后,调用修改Invoice的AM 方法**/
6
7 OAApplicationModule am = pageContext.getApplicationModule(webBean);
8
9 if (pageContext.getParameter("Apply") != null) {
10
11 OAViewObject vo = (OAViewObject)am.findViewObject("UpdateInvoiceVO1");
12
13 am.invokeMethod("AmUpdateApply", null);
14
15 TransactionUnitHelper.endTransactionUnit(pageContext,"UpdateInvoiceTxn");
16
17 pageContext.forwardImmediately("OA.jsp?page=/oracle/apps/bxj/ap/invoice/webui/SearchInvoicePG",
18
19 null,
20
21 OAWebBeanConstants.KEEP_MENU_CONTEXT,
22
23 null, null, true,
24
25 OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
26
27 } else if (pageContext.getParameter("Cancel") != null) {
28
29 am.invokeMethod("AmCreateRollback", null);
30
31 TransactionUnitHelper.endTransactionUnit(pageContext, "CreateInvoiceTxn");
32
33 pageContext.forwardImmediately("OA.jsp?page=/oracle/apps/bxj/ap/invoice/webui/SearchInvoicePG", null,
34
35 OAWebBeanConstants.KEEP_MENU_CONTEXT,
36
37 null,null,true,
38
39 OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
40
41 }
42
43 }
9. 在InvoiceAM中添加如下方法
1 /**修改Invoice,将资料做Commit**/
2
3 public void AmUpdateApply() {
4
5 getTransaction().commit();
6
7 }
Thanks and Regards
参考:Oracle Developer Guide
参考:王重东 OAF开发笔记
ERP技术讨论群: 288307890
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建