2014-09-14 Created By BaoXinjian
一、汇总
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中添加如下方法
public void processFormRequest(OAPageContext pageContext,OAWebBean webBean) {
super.processFormRequest(pageContext, webBean);
/**按下创建发票Button,页面跳转至创建发票页面**/
if (pageContext.getParameter("Create") != null) {
pageContext.setForwardURL("OA.jsp?page=/oracle/apps/bxj/ap/invoice/webui/CreateInvoicePG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null, null, true,
OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
OAWebBeanConstants.IGNORE_MESSAGES);
}
}
3. 建立CreateInvoicePG,设定Button Region和Main Region
4. CreateInvoiceCO.java中添加如下方法
public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
super.processRequest(pageContext, webBean);
/**初始化页面,调用创建Row的方式**/
if (!pageContext.isBackNavigationFired(false)) {
TransactionUnitHelper.startTransactionUnit(pageContext, "CreateInvoiceTxn");
if (!pageContext.isFormSubmission()) {
OAApplicationModule am = pageContext.getApplicationModule(webBean);
am.invokeMethod("AmCreateInvoice");
}
} else {
if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"CreateInvoiceTxn",true)) {
OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR);
pageContext.redirectToDialogPage(dialogPage);
}
}
OAApplicationModule am = pageContext.getApplicationModule(webBean);
am.invokeMethod("AmCreateInvoice", null);
}
5. 在InvoiceAM中添加如下方法
/**创建Invoice,初始化页面创建Row以存放资料**/
public void AmCreateInvoice() {
OAViewObject vo = (OAViewObject)getInvoiceCreateVO1();
vo.setMaxFetchSize(0);
vo.executeQuery();
Row row = vo.createRow();
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
}
6. CreateInvoiceCO.java中添加如下方法
public void processFormRequest(OAPageContext pageContext,OAWebBean webBean) {
super.processFormRequest(pageContext, webBean);
/**按下确定Button后,调用创建Invoice的AM 方法**/
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (pageContext.getParameter("Apply") != null) {
OAViewObject vo = (OAViewObject)am.findViewObject("CreateInvoiceVO1");
am.invokeMethod("AmCreateApply", null);
TransactionUnitHelper.endTransactionUnit(pageContext,"CreateInvoiceTxn");
pageContext.forwardImmediately("OA.jsp?page=/oracle/apps/bxj/ap/invoice/webui/SearchInvoicePG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null, null, true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
} else if (pageContext.getParameter("Cancel") != null) {
am.invokeMethod("AmCreateRollback", null);
TransactionUnitHelper.endTransactionUnit(pageContext, "CreateInvoiceTxn");
pageContext.forwardImmediately("OA.jsp?page=/oracle/apps/bxj/ap/invoice/webui/SearchInvoicePG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,null,true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}
7. 在InvoiceAM中添加如下方法
/**创建Invoice,将资料做Commit**/
public void AmCreateApply() {
getTransaction().commit();
}
8. SearchInvoiceCO.java中添加如下方法
public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
super.processRequest(pageContext, webBean);
/**从创建Invoice页面跳转至查询Invoice页面时,检查Create Invoice资料是否被Commit**/
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"CreateInvoice",false)) {
am.invokeMethod("AmCreateRollback");
TransactionUnitHelper.endTransactionUnit(pageContext, "CreateInvoiceTxn");
}
}
Thanks and Regards