2014-06-02
BaoXinjian
一、摘要
实现OAF的新增功能insert
二、案例
需求:创建新增功能
1.建立SearchInvoicePG对应的Create按钮以跳转到Create页面
2. SearchInvoiceCO.java中添加如下方法
3. 建立CreateInvoicePG,设定Button Region和Main Region
4. CreateInvoiceCO.java中添加如下方法
5. 在InvoiceAM中添加如下方法
6. CreateInvoiceCO.java中添加如下方法
7. 在InvoiceAM中添加如下方法
8. SearchInvoiceCO.java中添加如下方法
三、案例实现
1.建立SearchInvoicePG对应的Create按钮以跳转到Create页面
2. SearchInvoiceCO.java中添加如下方法
1 public void processFormRequest(OAPageContext pageContext,OAWebBean webBean) {
2
3 super.processFormRequest(pageContext, webBean);
4
5 /**按下创建发票Button,页面跳转至创建发票页面**/
6
7 if (pageContext.getParameter("Create") != null) {
8
9 pageContext.setForwardURL("OA.jsp?page=/oracle/apps/bxj/ap/invoice/webui/CreateInvoicePG",
10
11 null,
12
13 OAWebBeanConstants.KEEP_MENU_CONTEXT,
14
15 null, null, true,
16
17 OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
18
19 OAWebBeanConstants.IGNORE_MESSAGES);
20
21 }
22
23 }
3. 建立CreateInvoicePG,设定Button Region和Main Region
4. CreateInvoiceCO.java中添加如下方法
1 public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
2
3 super.processRequest(pageContext, webBean);
4
5 /**初始化页面,调用创建Row的方式**/
6
7 if (!pageContext.isBackNavigationFired(false)) {
8
9 TransactionUnitHelper.startTransactionUnit(pageContext, "CreateInvoiceTxn");
10
11 if (!pageContext.isFormSubmission()) {
12
13 OAApplicationModule am = pageContext.getApplicationModule(webBean);
14
15 am.invokeMethod("AmCreateInvoice");
16
17 }
18
19 } else {
20
21 if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"CreateInvoiceTxn",true)) {
22
23 OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR);
24
25 pageContext.redirectToDialogPage(dialogPage);
26
27 }
28
29 }
30
31 OAApplicationModule am = pageContext.getApplicationModule(webBean);
32
33 am.invokeMethod("AmCreateInvoice", null);
34
35 }
5. 在InvoiceAM中添加如下方法
1 /**创建Invoice,初始化页面创建Row以存放资料**/
2
3 public void AmCreateInvoice() {
4
5 OAViewObject vo = (OAViewObject)getInvoiceCreateVO1();
6
7 vo.setMaxFetchSize(0);
8
9 vo.executeQuery();
10
11 Row row = vo.createRow();
12
13 vo.insertRow(row);
14
15 row.setNewRowState(Row.STATUS_INITIALIZED);
16
17 }
6. CreateInvoiceCO.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("CreateInvoiceVO1");
12
13 am.invokeMethod("AmCreateApply", null);
14
15 TransactionUnitHelper.endTransactionUnit(pageContext,"CreateInvoiceTxn");
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",
34
35 null,
36
37 OAWebBeanConstants.KEEP_MENU_CONTEXT,
38
39 null,null,true,
40
41 OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
42
43 }
44
45 }
7. 在InvoiceAM中添加如下方法
1 /**创建Invoice,将资料做Commit**/
2
3 public void AmCreateApply() {
4
5 getTransaction().commit();
6
7 }
8. SearchInvoiceCO.java中添加如下方法
1 public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
2
3 super.processRequest(pageContext, webBean);
4
5 /**从创建Invoice页面跳转至查询Invoice页面时,检查Create Invoice资料是否被Commit**/
6
7 OAApplicationModule am = pageContext.getApplicationModule(webBean);
8
9 if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"CreateInvoice",false)) {
10
11 am.invokeMethod("AmCreateRollback");
12
13 TransactionUnitHelper.endTransactionUnit(pageContext, "CreateInvoiceTxn");
14
15 }
16
17 }
Thanks and Regards
时间: 2024-10-10 02:13:36