How to Create OAF Insert Page / Data Entry OAF Page / Inserting Data into Database in R12.1.3/R12.2.6
How to Create OAF Insert Page / Data Entry OAF Page / Inserting Data into Database in R12.1.3/R12.2.6
Please refer this post for the Table Script Table Script
Step 1: Create a New Work space and Project
Step 2: Create a New Entity Object
Right click on Current Work space -> Business Tier -> Entity Object
Select the Table created earlier .Make sure Package is under server.schema as shown below
Since Primary Key does not Exists in table ,Wizard will Generate a ROWID By default.
Step 3: Create a New View Object (VO)
Generate VO from the EO Generated above.make sure you generate VOImpl and VORowImpl
Once finished Step 2 , 3 final One will look line the below in the Application Navigator
Step 4: Attach View Object (VO) to Application Module (AM)
Set below Property to AM since this AM we will be using for Insert,Update ,Delete operations also.
Right click on SearchAppAM -> Edit SearchAppAM -> Custom Properties
Name RETENTION_LEVEL
Value MANAGE_STATE
Step 5: Create a New Page for Insert Operation
Name InsertPG
Package xxdcb.oracle.apps.fnd.webui
Set the below properties for the page.
ID
|
PageLayoutRN
|
Region Style
|
pageLayout
|
AM Definition
|
xxdcb.oracle.apps.fnd.server.SearchAppAM
|
Window
|
Create Employee
|
Title
|
Create Employee
|
Step 6 : Create a New Message Component Region under PageLayout Region
Repeat step 13 to create
EmployeeId
LastName
FirstName
Salary
StartDate
Position
Manager Name
Step 8: Create a New Button Bar Region and Insert Action Buttons
Right click on PageLayoutRN -> New -> Region
ID InsertPageButtonsRN
Region Style pageButtonBar
Create Apply and Cancel Buttons for Insert Record Page
Right click on InsertPageButtonsRN -> New -> Item
ID
|
Create
|
Region Style
|
submitButton
|
Construction Mode
|
/oracle/apps/fnd/attributesets/Buttons/Create
|
ID
|
Cancel
|
Region Style
|
submitButton
|
Construction Mode
|
/oracle/apps/fnd/attributesets/Buttons/Cancel
|
Step 9: Create a New Controller for Insert Page
Right click on PageLayoutRN -> Set New Controller
Package Name xxdcb.oracle.apps.fnd.webui
Class Name InsertEmployeeCO
Step 10: Add the following code under SearchAppAMImpl.java file
public void apply(){
getOADBTransaction().commit();
}
public void rollback(){
getOADBTransaction().rollback();
}
public void createRecord()
{
OAViewObject vo = getXxdcbEmployeeEVO();
if (!vo.isPreparedForExecution())
{
vo.executeQuery();
}
Row row = vo.createRow();
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
}
Step 11: Add the below code in EmployeeSearchCO.java under processFormRequest method.
if (pageContext.getParameter("Create") != null)
{
pageContext.forwardImmediately(
"OA.jsp?page=/xxdcb/oracle/apps/fnd/webui/InsertPG",
null, OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
Step 12: Add the below code in InsertEmployeeCO.java
package xxdcb.oracle.apps.fnd.webui;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
/**
* Controller for ...
*/
public class InsertEmployeeCO extends OAControllerImpl
{
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
am.invokeMethod("createRecord", null);
}
/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
// Pressing the "Apply" button means the transaction should be
// validated and committed.
if (pageContext.getParameter("Create") != null)
{
OAException message = new OAException("Record has been Inserted!", OAException.INFORMATION);
pageContext.putDialogMessage(message);
am.invokeMethod("apply");
pageContext.forwardImmediately(
"OA.jsp?page=/xxdcb/oracle/apps/fnd/webui/EmpSearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
else if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollback");
pageContext.forwardImmediately("OA.jsp?page=/xxdcb/oracle/apps/fnd/webui/EmpSearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}
}
Step 13: Create a New Record and Verify
Post a Comment