Now that we are able to Insert record into tables and search for records from a OAF screen, it makes sense that the OAF screen should allow us to update the records in the table as well. So, here it goes, below are the steps that shows updation of records in a table from a OAF screen.
Requirement: To update records in a table from OAF screen
Step 1: Complete creating a workspace and project as in Search Record article
Step 2: Create an Update action item
Right click on table region SearchRecordVO1 -> New -> Item
Set the properties of the item created as shown below:
Click on browse button for parameters under Client action pane and enter the parameter name and values
Name – updateColumn1
Value -- ${oa.SearchRecordVO1.Column1}
Name – updateColumn2
Value -- ${oa.SearchRecordVO1.Column2}
Step 3: Create a OA Components page
Right click on SearchRecord project -> click New -> select OA components under Web Tier -> select Page
Package: oaf.oracle.apps.fnd.searchrecord.webui
Page Name: UpdateRecordPG
Step 4: Set Page properties
Select on the UpdateRecordPG page and go to structure pane where a region of type 'pageLayout' and ID 'region1' is automatically created.
Click on region1 in structure page and set the project properties as in the below screenshot - set all the properties except the controller class, for now.
Step 5: Set new Controller
Select PageLayoutRN in the structure pane -> Right click on it -> Set new controller
Package: oaf.oracle.apps.fnd.searchrecord.webui
Controller name: UpdateRecordCO
This automatically sets the controller class property in UpdateRecordPG page properties.
Step 6: Create region in UpdateRecordPG
Right click on PageLayoutRN -> New -> Region
Now, this creates a new region of style header under PageLayoutRN
Select region1 - set the ID as MainRN and set the region style to messageComponentLayout
Step 7: Create item in MainRN
Right click on MainRN > New > messageTextInput
Set the properties of the item as in screenshot below:
Create one another item similar to the above one and set it properties as below:
Step 8: Add Apply and Cancel buttons
Right click on PageLayoutRN > New > Region
ID -> Buttons
Region Style -> pageButtonBar
Right click on Buttons -> New -> Item
Attribute Set -> /oracle/apps/fnd/attributesets/Buttons/Apply
Enter the properties for the item as in the below Screenshot
Similarly create one more item for Cancel button
Attribute Set -> /oracle/apps/fnd/attributesets/Buttons/Cancel
Enter the properties for the item as in the below Screenshot
Step 9: Add a return navigation link to UpdateRecordPG
PageLayoutRN -> New -> returnNavigation
ID –> return
Set Destination URI as -> OA.jsp?page=/oaf/oracle/apps/fnd/searchrecord/webui/SearchRecordPG&retainAM=Y
Text –> Return to SearchRecordPG
Final page layout looks as below:
Step 10: Add the below code in SearchRecordCO:
PFR:
if ("update".equals(pageContext.getParameter(EVENT_PARAM)))
{
pageContext.setForwardURL("OA.jsp?page=/oaf/oracle/apps/fnd/searchrecord/webui/UpdateRecordPG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, OAWebBeanConstants.ADD_BREAD_CRUMB_NO, OAWebBeanConstants.IGNORE_MESSAGES);
}
Step 10: Add the below code in SearchRecordAMImpl
public void updateRow(String Column1, String Column2)
{
SearchRecordVOImpl vo = (SearchRecordVOImpl)getSearchRecordVO1();
vo.initQuery(Column1, Column2);
}
public void apply()
{
getTransaction().commit();
}
public void rollback()
{
getTransaction().rollback();
}
Step 11: Add the below code in SearchRecordVOImpl
public void initQuery(String Column1, String Column2)
{
if ((Column1 != null) && (!("".equals(Column1.trim()))))
{
setWhereClause("column1 = :1 AND column2 = :2");
setWhereClauseParams(null); // Reset always
setWhereClauseParam(0, Column1);
setWhereClauseParam(1, Column2);
executeQuery();
}
}
Step 12: Add the below code in UpdateRecordCO
PR:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
String Column1 = pageContext.getParameter("PColumn1");
String Column2 = pageContext.getParameter("PColumn2");
Serializable[] params = { Column1, Column2 };
am.invokeMethod("updateRow", params);
PFR:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (pageContext.getParameter("Apply") != null)
{
am.invokeMethod("apply");
OAException message = new OAException("Record has been Updated successfully!", OAException.INFORMATION);
pageContext.putDialogMessage(message);
}
else if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollback");
pageContext.forwardImmediately("OA.jsp?page=/oaf/oracle/apps/fnd/searchrecord/webui/SearchRecordPG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, false, // retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
Result:
Search for data and click on update pencil icon in column 3:
Update record for column2 from efgh to pqrs:
Hit Apply:
Return back to search page to see the updated result:
Comments
Error(15,10): duplicate definition of method initQuery(java. lang.String, java.lang.Strin g, java.lang.Strin g) in class xxapps.oracle.a pps.fnd.M_Searc hRecord_1.serve r.M_SearchRecor d_1VOImpl
OAException message = new OAException("Re cord has been Updated successfully!", OAException.INF ORMATION);
private class OAException {
RSS feed for comments to this post