Here we will create an another page and call from search page and do create another record or update the record in update page and return back to the search page.
1> Create an edit icon
Right click on table type object and create a new item of type image, change below properties
Item style > image
Prompt > Edit
Image URL > updateicon_enabled.gif
(These images are there in C:\Jdeveloper\jdevhome\jdev\myhtml\OA_MEDIA)
Action Type > fireaction
Event > updateRecord
Parameters > create parameter which can be primary key, here I am creating based on these two columns
PPensionOption ${oa.xxhwHrNicVO1.PensionOption}
PLowerLimit ${oa.xxhwHrNicVO1.LowerLimit}
2> Create an update page
>> /xxhw/oracle/apps/per/nic/webui/xxhwHrNicUpdPG
ID > PageLayoutRN
Region Style > pageLayout
Use same CO and AM
Window Title and Title > Update National Insurance Contributions
3> Right click the layout region and create new region using wizard, select same AM and VO as the search page.
4> Set a new controller for new page, name it as 'xxhwHrNicUpdCO'
5> Create new 'messageComponentLayout' (ButtonRN) under it
> and 'messageLayout' under it.
6. Create 4 items with property > submitButton
We will write the insert logic for 'Split' button
7> For 'Split' button set Action Type > fireaction and set parameters
PSPensionOption ${oa.xxhwHrNicVO1.PensionOption}
PSLowerLimit ${oa.xxhwHrNicVO1.LowerLimit}
PSUpperLimit ${oa.xxhwHrNicVO1.UpperLimit}
PSNicPercentage ${oa.xxhwHrNicVO1.NicPercentage}
PSRebate ${oa.xxhwHrNicVO1.Rebate}
PSDescription ${oa.xxhwHrNicVO1.Description}
> These parameter values will be used for new record creration
8> Now it is time to write some logic.
Go to the controller of the main page and handle logic for the newly added 'Edit' icon.
In the processFormRequest of xxhwHrNicCO add below code
//Logic for edit icon
//Initialising attribute to get value of any event (Note we have added edit button as event)
String actionFired = pageContext.getParameter("event");
//It will get parameter created in Edit button
String PPensionOption = pageContext.getParameter("PPensionOption");
String PLowerLimit = pageContext.getParameter("PLowerLimit");
//Now logic is:
if(actionFired.equals("updateRecord"))
{
// create a hash map and put values for parameters and action
HashMap phm = new HashMap();
phm.put("xxPPensionOption", PPensionOption);
phm.put("xxPLowerLimit", PLowerLimit);
phm.put("xxActionOnRecord", actionFired);
// go to update page
pageContext.setForwardURL("OA.jsp?page=/xxhw/oracle/apps/per/nic/webui/xxhwHrNicUpdPG", null, (byte)0, null, phm, true, "N", (byte)99);
}
9> Run the page
10> Go
11> Click on the edit icon and you can see the update page with one record
12> Now add logic to handle
Edit and (Split Record or Insert) button
> Create a method ' updateRecordMethod' in Application Module '
xxhwHrNicAMImpl'
public void updateRecordMethod(String pAction, String PPensionOption, String PLowerLimit)
{
try
{
System.out.println("Inside xxhwHrNicAMImpl.updateRecordMethod");
OAViewObjectImpl pervo = getxxhwHrNicVO1();
String existingWhereClause = pervo.getWhereClause();
pervo.setWhereClauseParams(null);
pervo.setWhereClause("PENSION_OPTION = :1 AND LOWER_LIMIT = to_number(:2)");
pervo.setWhereClauseParam(0, PPensionOption);
pervo.setWhereClauseParam(1, PLowerLimit);
pervo.executeQuery();
pervo.setWhereClauseParams(null);
pervo.setWhereClause(existingWhereClause);
}
catch(Exception exception1)
{
throw OAException.wrapperException(exception1);
}
}
> Now change the Controller of Update Page --
xxhwHrNicUpdCO
In the
processrequest
> Get all the parameter values and execute query based on these parameters
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
super.processRequest(pageContext, webBean);
String actionOnRecord = pageContext.getParameter("xxActionOnRecord");
String PPensionOption = pageContext.getParameter("xxPPensionOption");
String PLowerLimit = pageContext.getParameter("xxPLowerLimit");
OAApplicationModule recAM = pageContext.getApplicationModule(webBean);
Serializable recordParamList[] = {
actionOnRecord, PPensionOption, PLowerLimit
};
if(actionOnRecord != null && actionOnRecord.equals("updateRecord"))
{
recAM.invokeMethod("updateRecordMethod", recordParamList);
}
}
>> Done with the Edit button logic.
>> Do the same for Cancel and Save button logic what you did in Main page
>> Now add
logic for 'Split Record ' Button, it should create a new record with some values from parent record.
> Create another method
insertRecord in Application Module
xxhwHrNicAMImpl
public void insertRecord(String PSPensionOption, String PSLowerLimit, String PSUpperLimit, String PSNicPercentage, String PSRebate, String PSDescription)
{
OAViewObjectImpl HrNicVOImpl = (OAViewObjectImpl)getxxhwHrNicVO1();
Row hrnicrow = HrNicVOImpl.createRow();
hrnicrow.setAttribute("PensionOption", PSPensionOption);
hrnicrow.setAttribute("LowerLimit", 0);// PSLowerLimit);
hrnicrow.setAttribute("UpperLimit", 0);//PSUpperLimit);
hrnicrow.setAttribute("NicPercentage", PSNicPercentage);
hrnicrow.setAttribute("Rebate", PSRebate);
hrnicrow.setAttribute("Description", PSDescription);
HrNicVOImpl.insertRow(hrnicrow);
hrnicrow.setNewRowState((byte)-1);
getTransaction().commit();
}
>> Update the
Processformrequest of the update page controller
xxhwHrNicUpdCO
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
String actionFired = pageContext.getParameter("event");
String PSPensionOption = pageContext.getParameter("PSPensionOption");
String PSLowerLimit = pageContext.getParameter("PSLowerLimit");
String PSUpperLimit = pageContext.getParameter("PSUpperLimit");
String PSNicPercentage = pageContext.getParameter("PSNicPercentage");
String PSRebate = pageContext.getParameter("PSRebate");
String PSDescription = pageContext.getParameter("PSDescription");
Serializable pcardList[] = {
PSPensionOption, PSLowerLimit, PSUpperLimit, PSNicPercentage, PSRebate, PSDescription
};
if (pageContext.getParameter("Save") != null)
{
am.getOADBTransaction().commit();
}
else if (pageContext.getParameter("Cancel") != null)
{
am.getOADBTransaction().rollback();
}
// if retuen then return for Main page
else if (pageContext.getParameter("Return") != null)
{
pageContext.setForwardURL("OA.jsp?page=/xxhw/oracle/apps/per/nic/webui/xxhwHrNicPG", null, (byte)0, null, null, true, "N", (byte)99);
}
// if splitrecord then call a insertrecord method with all the parameter values
if(actionFired.equals("splitRecord"))
{
am.invokeMethod("insertRecord", pcardList);
}
}
13> Run the page again
On the update page click on 'Split Record' button
Change and save, return to the main page.
Done. :)
>> Now it's time to
deploy your custom page and access from application