Build a Create Page in OAF
Transcript of Build a Create Page in OAF
-
7/31/2019 Build a Create Page in OAF
1/12
Build a Create Page in OAF!
Here I am posting a step by step tutorial to build a simple CREATE page in OAF. It is a
continuation of an earlier tutorial and so you need to go through that first before going
through this.
Here is the link: Build Simple Search Page in OAFStep1: Build a Create Button
Select the view EmpSearchPG, right click and select New > TableActions. One
region (region1) will be created with region style as FlowLayout.
Change the ID of the above newly created region to ButtonLayoutRN.
Right click ButtonLayoutRN and create a new Item.
Set the below details for the Item
o ID :Create
o Item Style : submitButton
o Attribute
Set:/oracle/apps/fnd/framework/toolbox/attributesets/FwkTbxEmployees/Create
Employee
o Action Type: fireAction
o Event: create
http://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.htmlhttp://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.htmlhttp://imdjkoch.files.wordpress.com/2011/05/1-create-a-button.jpghttp://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.htmlhttp://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.html -
7/31/2019 Build a Create Page in OAF
2/12
Step 2: Set a Controller
Right clickPageLayoutRN and select Set New Controller.
Give the package name as xxhci.oracle.apps.custom.LabExamples.webui.
Give the class name as EmpSearchCO.
Add the following logic to processFormRequest of EmpSearchCO.java after
super.processFormRequest method.if (pageContext.getParameter("event").equalsIgnoreCase("create")) {
http://imdjkoch.files.wordpress.com/2011/05/3-set-new-controller.jpghttp://imdjkoch.files.wordpress.com/2011/05/2-create-button-properties.jpg -
7/31/2019 Build a Create Page in OAF
3/12
System.out.println("EmpSearchCO: processing create/update");pageContext.setForwardURL("OA.jsp?page=/xxhci/oracle/apps/custom/LabExamples/webui/EmployeeCreatePG",null,OAWebBeanConstants.KEEP_MENU_CONTEXT,null, null, true,OAWebBeanConstants.ADD_BREAD_CRUMB_YES,OAWebBeanConstants.IGNORE_MESSAGES);}
You might get red lines under java classes which are not imported. Bring the cursor on
these red-lined text and click Alt+Enter (JDev automatically tells you to import the class
using Alt+Enter when you move cursor over these lines).Step 3: Build the Create Employee Page (EmployeeCreatePG)
Right click on Project >New >Web Tier >OA Components Page.
Set the Page name as EmployeeCreatePG
Set the package name as xxhci.oracle.apps.custom.LabExamples.webui
Select the pageLayout region of EmployeePG and assign the properties as below
ID : PageLayoutRN
AM Definition :
xxhci.oracle.apps.custom.LabExamples.server.XxhciOafTrngEmpTabAM
Window Title : Employee WindowTitle: Employee
Warn About Change: True
http://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.htmlhttp://imdjkoch.files.wordpress.com/2011/05/4-build-the-create-employee-page.jpghttp://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.html -
7/31/2019 Build a Create Page in OAF
4/12
Step 4: Add items to Create Employee Page
Create a region under PageLayoutRN and assign ID as PageButtonsRN.
Set the region style as pageButtonBar
http://imdjkoch.files.wordpress.com/2011/05/5-create-employee-page-properties.jpg -
7/31/2019 Build a Create Page in OAF
5/12
Now we need to create two buttons in this region as APPLY and CANCEL.
For Apply Button:
Right click on PageButtonsRN > New > Item.
Set the properties as
ID :ApplyItem Style :submitButton
Attribute Set : /oracle/apps/fnd/attributesets/Buttons/Apply
Additional Text :Click to save the transaction
Action Type: fireAction
Event: Apply
For Cancel Button:
Right click on PageButtonsRN > New > Item.
Set the properties as
ID : Cancel
Item Style : submitButton
Attribute Set :/oracle/apps/fnd/attributesets/Buttons/CancelAdditional Text : Click to cancel the transaction
Action Type: fireAction
Event: Cancel
Fortext items in page: Right click on PageLayoutRN New Region using wizard.
Enter data as shown in below screenshots
http://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.htmlhttp://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.htmlhttp://imdjkoch.files.wordpress.com/2011/05/6-apply-and-cancel-button.jpghttp://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.html -
7/31/2019 Build a Create Page in OAF
6/12
Step 4.1: Select AM and VO instance created during search page
Step 4.2: Give Region ID as MainRN and Region Style as defaultSingleColumn
http://imdjkoch.files.wordpress.com/2011/05/8-step2-region-properties.jpghttp://imdjkoch.files.wordpress.com/2011/05/7-step1-vo-instance-created-during-search-page.jpg -
7/31/2019 Build a Create Page in OAF
7/12
Step 4.3: Select attributes as below (EmpNo, EmpName and Department)
Step 4.4: Change the prompts of items as shown below (messageInputText)
http://imdjkoch.files.wordpress.com/2011/05/10-step4-region-items.jpghttp://imdjkoch.files.wordpress.com/2011/05/9-step3-view-properties.jpg -
7/31/2019 Build a Create Page in OAF
8/12
Click on finish for step 5.
Change the Region Style forMainRN to messageComponentLayout. This is done now as
above region wizard, doesnt have support for messageComponentLayout. Click on Yesbutton when the confirm window pops for change of region style.
Step5: Adding Model Layer Code
Add following code to XxhciOafTrngEmpTabAMImpl.java. Add import statements atthe start and rest of the methods with the class definition.import oracle.jbo.Row;import oracle.apps.fnd.framework.OAViewObject;import oracle.jbo.Transaction;import oracle.jbo.domain.Number;import oracle.jbo.RowSetIterator;
// Creates a new employee.
public void createEmployee(){OAViewObject vo = (OAViewObject)getXxhciOafTrngEmpTabEOView1();// Per the coding standards, this is the proper way to
initialize a// VO that is used for both inserts and queries. See View
Objects// in Detail in the Developer's Guide for additional
information.if (!vo.isPreparedForExecution()){vo.executeQuery();}Row row = vo.createRow();vo.insertRow(row);// Required per OA Framework Model Coding Standard M69row.setNewRowState(Row.STATUS_INITIALIZED);
} // end createEmployee()
// Executes a rollback including the database and the middletier.
public void rollbackEmployee(){Transaction txn = getTransaction();// This small optimization ensures that we don't perform a
rollback// if we don't have to.if (txn.isDirty()){txn.rollback();}}
//Commits the transaction.
public void apply(){getTransaction().commit();}
-
7/31/2019 Build a Create Page in OAF
9/12
Add the following import statement and modify the create method in
XxhciOafTrngEmpTabEOImpl as follows:Add this as a part of import statementsimport oracle.apps.fnd.framework.server.OADBTransaction;
Modify the create method as belowpublic void create(AttributeList attributeList) {
super.create(attributeList);OADBTransaction transaction = getOADBTransaction();Number employeeId =
transaction.getSequenceValue("FWK_TBX_EMPLOYEES_S");setEmpNo(employeeId.toString());
}
Step6: Add Controller logic for Create Employee Page
Right click on PageLayoutRN of EmployeeCreatePG > Set New Controller.Give the values as
Package : xxhci.oracle.apps.custom.LabExamples.webui
Class Name : EmployeeCO
Add the below code to the new CO
Import Statements:import java.io.Serializable;import oracle.apps.fnd.common.MessageToken;import oracle.apps.fnd.framework.OAApplicationModule;import oracle.apps.fnd.framework.OAException;import oracle.apps.fnd.framework.OAViewObject;import oracle.apps.fnd.framework.webui.OADialogPage;import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
processRequest (after super.processRequest):if (!pageContext.isBackNavigationFired(false)) {
OAApplicationModule am =pageContext.getApplicationModule(webBean);
am.invokeMethod("createEmployee");
} else {// We got here through some use of the browser "Back"
button, so we// want to display a stale data error and disallow
access to theOADialogPage dialogPage = new
OADialogPage(STATE_LOSS_ERROR);pageContext.redirectToDialogPage(dialogPage);
}
processFormRequest (after super.processFormRequest):OAApplicationModule am =
pageContext.getApplicationModule(webBean);// Pressing the "Apply" button means the transaction should
be validated// and committed.
if (pageContext.getParameter("event").equalsIgnoreCase("Apply")) {OAViewObject vo =
(OAViewObject)am.findViewObject("XxhciOafTrngEmpTabEOView1");
String employeeName =(String)vo.getCurrentRow().getAttribute("EmpName"
);String employeeNum =
-
7/31/2019 Build a Create Page in OAF
10/12
(String)vo.getCurrentRow().getAttribute("EmpNo");am.invokeMethod("apply");MessageToken[] tokens ={ new MessageToken("EMP_NAME", employeeName),new MessageToken("EMP_NUMBER", employeeNum) };
OAException confirmMessage =new OAException("AK",
"FWK_TBX_T_EMP_CREATE_CONFIRM", tokens,OAException.CONFIRMATION, null);
pageContext.putDialogMessage(confirmMessage);pageContext.forwardImmediately("OA.jsp?
page=/xxhci/oracle/apps/custom/labExamples/webui/EmpSearchPG",null,OAWebBeanConstants
.KEEP_MENU_CONTEXT,null, null, true,OAWebBeanConstants
.ADD_BREAD_CRUMB_NO);}
// If Cancel button is pressed, rollback the transaction
else if(pageContext.getParameter("event").equalsIgnoreCase("Cancel")) {
am.invokeMethod("rollbackEmployee");pageContext.forwardImmediately("OA.jsp?
page=/xxhci/oracle/apps/custom/labExamples/webui/EmpSearchPG",null,OAWebBeanConstants
.KEEP_MENU_CONTEXT,null, null, false,OAWebBeanConstants
.ADD_BREAD_CRUMB_NO);
}
Step 7: Save all and Run the EmpSearchPG to test the page
-
7/31/2019 Build a Create Page in OAF
11/12
Flow Diagram
http://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.htmlhttp://imdjkoch.files.wordpress.com/2011/05/flow-diagram.jpghttp://oracleappsa2z.blogspot.com/2011/09/build-create-page-in-oaf.html -
7/31/2019 Build a Create Page in OAF
12/12