Update Page in OAF
Now we are going to learn how to update the records
in database.
For that now create the page for update and attach
the AM.
Create the items similar to Employee Creation page
or Go to Employee Creation page and copy the region and paste here.
Next create two button for update and cancel.
The page structure of update page is like this.
Create one controller for Update page.
For update
first create one item in the search page for update.
Set
the following properties.
Item style:-
image
Image URI:-/OA_MEDIA/<name of the image> (/OA_MEDIA/updateicon_enabled.gif)
Copy the image in both server and local machine
OA_MEDIA directory.
Client Action
:-
Action
type:- fire Action
Event :- update.
Parameters:-
name:- Any name (uemp)
Value:-${OA.<Search page view instance>.<Primary
key attribute name>}
${oa.SearchVO1.EmployeeId}
the page look like as follows.
After clicking the update icon it should call the
upadate page along with the data.
For that write the following code in the controller
of search page in processFormRequest
if("update".equals(pageContext.getParameter(EVENT_PARAM)))
{
pageContext.setForwardURL("OA.jsp?page=/sangu/oracle/apps/po/searchPRJ/webui/UpdatePG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true,
OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
OAWebBeanConstants.IGNORE_MESSAGES);
}
Note:-
In
the above code update is the event
name given in the item properties
After calling the update page it should carry the data also.
i.e on page load of update page it should display
the data of selected record for that write the following code in processRequest of update page
controller.
/*For
Copy Paste */
public void
processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
/* Initialize the AM */
searchAMImpl am= (searchAMImpl)pageContext.getApplicationModule(webBean);
/* Check for parameter */
/* uemp
is the name of the parameter given in the item properties of upadate item */
if(pageContext.getParameter("uemp")!=null)
{
String hid = pageContext.getParameter("uemp").toString();
/*EMPLOYEE_ID is the column name in the
database */
String whereclause =
"EMPLOYEE_ID='"+hid+"'";
am.getEmployeesVO1().setWhereClause(null);
am.getEmployeesVO1().setWhereClause(whereclause);
am.getEmployeesVO1().executeQuery();
}
else
{
/*
If there is no data then call create employee method */
am.insertData();
}
}
After click on update image it will call update page
along with data The output will look like this.
After making all the changes and on click of the
update it should save the updated data for that
Write the following code in processFormRequest of update page controller.
/*For
Copy Paste */
public void
processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
/* Initialize the AM */
searchAMImpl am= (searchAMImpl)pageContext.getApplicationModule(webBean);
/*For
updating the data */
if
(pageContext.getParameter("item1")!=null) //id of update button
{
am.getOADBTransaction().commit();
throw new
OAException("Employee Data Updated
Successfully",OAException.CONFIRMATION);
}
/*
After clicking the cancel button it shuld redirect to search page */
if(pageContext.getParameter("item2")!=null) //id of cancele button
{
pageContext.setForwardURL("OA.jsp?page=/sangu/oracle/apps/po/searchPRJ/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true,
OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
OAWebBeanConstants.IGNORE_MESSAGES);
}
}
Run the page to see the output.
After making the changes on the page.
After click on update button it will update the data
successfully.
To check once again go back to search page and
search the record it will display the updated data.
HI
ReplyDeleteSangu Patil
Can we do multiple update on same page with out navigation if it is possible can you give example on that please
Thanks
Vamshi S
Hi Vanshi,
ReplyDeleteIf your search page vo is based on EO then in the search page only u edit the information and after click on update
write the below code
am.getOADBTransaction().commit();
If your search vo is not based on EO or for updating records you want to call procedure then
the method where you call procedure in that
inisialize the array descriptor.
collect all the information on the page into the array and pass the array to procedure in procedure you can update multiple recordds.
Regards,
Sangu
Hi,
ReplyDeleteThank you for this tutorial.. but when i click on Update button nothing happen...
Why ?
Please advise.
Joe
am.getEmployeesVO1().setWhereClause(null);
ReplyDeleteam.getEmployeesVO1().setWhereClause(whereclause);
am.getEmployeesVO1().executeQuery();
Good Evening Sir,This code i not understand please Can u Explain am.getEmployeesVO1()
I also same doubt. pls any one solve this
DeleteHII Sir,
ReplyDeleteThank so much Sir,
I have a doubt on this line am.getEmployeesVO1().setWhereClause(null);
here EmployeesVO1 it is a vo,which vo sir,It is a search vo or create vo
am.getEmployeesVO1().setWhereClause(null);
ReplyDeleteam.getEmployeesVO1().setWhereClause(whereclause);
am.getEmployeesVO1().executeQuery();
I stuck here. Pls any one help me.
This comment has been removed by the author.
ReplyDelete