Wednesday, January 7, 2015

Update Records in OAF

Pre-Requisite

Do complete the Search Page in OAF

Step 1: Create a New Item for Update Action

Right click on SearchTable -> New -> Item


Update the Properties
Attribute
Property
ID
Update
Item Style
image
Atribute Set
/oracle/apps/fnd/attributesets/Buttons/Update
Prompt
Update
Image URI
updateicon_enabled.gif
Additional Text
Update record
Height
24
Width
24
Action Type
fireAction
Event
update
Submit
TRUE
Parameters
Name
Value
PPersonType
${oa.SearchVO.PersonType}
PPersonName
${oa.SearchVO.PersonName}
PEmailAddresss
${oa.SearchVO.EmailAddresss}
PContactNumber
${oa.SearchVO.ContactNumber}




Step 2: Create a New Page for Update Action

Right click on SearchProj-> New -> Web Tier -> OA Components -> Page

Step 3: Update the Properties and Create the Region (MainRN)

ID
PageLayoutRN
Region Style
pageLayout
AM Definition
oracle.apps.fnd.searchproj.server.SearchAM
Window Title
Update Page Window
Title
Update Page



Right click on PageLayoutRN -> New -> Region
ID
MainRN
Region Style
messageComponentLayout


Step 4: Create the Items for Update Required Fields
Right Click on MainRN -> New -> messageTextInput

Item1 -> PersonType
Item2 -> PersonName
Item 3 -> EmailAddresss
Item 4 -> ContactNumber

Update the Properties

ID
PersonType
Region Style
messageTextInput
Data Type
VARCHAR2
Maximum Length
100
View Instance
SearchVO
View Attribute
PersonType
Prompt
PersonType
Length
20

ID
PersonName
Region Style
messageTextInput
Data Type
VARCHAR2
Maximum Length
200
View Instance
SearchVO
View Attribute
PersonName
Prompt
PersonName
Length
20

ID
EmailAddresss
Region Style
messageTextInput
Data Type
VARCHAR2
Maximum Length
100
View Instance
SearchVO
View Attribute
EmailAddresss
Prompt
EmailAddresss
Length
20

ID
ContactNumber
Region Style
messageTextInput
Data Type
VARCHAR2
Maximum Length
100
View Instance
SearchVO
View Attribute
ContactNumber
Prompt
ContactNumber
Length
20


Step 5: Create the Region for Action Buttons

Right click on MainRN -> New -> messageLayout

Update the Properties
ID            ButtonLayout
Step 6: Create the Action Buttons
Right click on ButtonLayout -> New -> Item

Item 1 -> Apply
Item 2 -> Cancel

Update the Properties

ID
Apply
Region Style
submitButton
Attribute Set
/oracle/apps/fnd/attributesets/Buttons/Apply

ID
Cancel
Region Style
submitButton
Attribute Set
/oracle/apps/fnd/attributesets/Buttons/Cancel

Step 7: Search Page Controller
Select SearchPG.xml
Right click on PageLayoutRN -> Set New Controller


Package Name      :               oracle.apps.fnd.searchproj.webui

Class Name            :               SearchCO

 Add the following code in SearchCO.java
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;

Replace the processRequest with the following code

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);

OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");
queryBean.clearSearchPersistenceCache(pageContext);
}

Replace the processFormRequest with the following code

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processFormRequest(pageContext, webBean);
  
 if ("update".equals(pageContext.getParameter(EVENT_PARAM)))
 {
  pageContext.setForwardURL("OA.jsp?page=/oracle/apps/fnd/searchproj/webui/UpdatePG",
                                    null,
                                    OAWebBeanConstants.KEEP_MENU_CONTEXT,                            
                                    null,                                                    
                                    null,
                                    true,                            
                                    OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
                                    OAWebBeanConstants.IGNORE_MESSAGES);
 } 
}

Step 7: Update Page Controller
Select UpdatePG.xml
Right click on PageLayoutRN -> Set New Controller


Package Name      :               oracle.apps.fnd.searchproj.webui
Class Name            :               UpdateCO



Add the following code in UpdateCO.java

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.OAApplicationModule;
import java.io.Serializable;

Replace the processRequest with the following code

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);

String PersonType = pageContext.getParameter("PPersonType");
String PersonName = pageContext.getParameter("PPersonName");
String EmailAddresss = pageContext.getParameter("PEmailAddresss");
String ContactNumber = pageContext.getParameter("PContactNumber");

Serializable[] params = { PersonType, PersonName, EmailAddresss, ContactNumber };

am.invokeMethod("updateRow", params);
}

Replace the processFormRequest with the following code

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processFormRequest(pageContext, webBean);
  
 if ("update".equals(pageContext.getParameter(EVENT_PARAM)))
 {
  pageContext.setForwardURL("OA.jsp?page=/oracle/apps/fnd/searchproj/webui/UpdatePG",
                                    null,
                                    OAWebBeanConstants.KEEP_MENU_CONTEXT,                            
                                    null,                                                   
                                    null,
                                    true,                            
                                    OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
                                    OAWebBeanConstants.IGNORE_MESSAGES);
 } 
}


Step 8: Add the code in SearchAMImpl.java
Add the following code in SearchAMImpl.java

import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;

public void updateRow(String PersonType, String PersonName, String EmailAddresss, String ContactNumber)
{
 SearchVOImpl vo = (SearchVOImpl)getSearchVO();
 vo.initQuery(PersonType, PersonName, EmailAddresss, ContactNumber);
}
   
public void apply()
{
 getTransaction().commit();
}

public void rollback()
{
 getTransaction().rollback();
}

Step 9: Add the code in SearchVOImpl.java
Right Click on SearchVO -> Java -> check the below check boxes.

Add the following code in SearchVOImpl.java

import oracle.apps.fnd.framework.server.OAViewObjectImpl;

public void initQuery(String PersonType, String PersonName, String EmailAddresss, String ContactNumber)
{
if ((PersonType != null) && (!("".equals(PersonType.trim()))))
{
setWhereClause("Person_Type = :1 AND Person_Name = :2 AND Email_Addresss = :3 AND Contact_Number = :4");
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, PersonType);
setWhereClauseParam(1, PersonName);
setWhereClauseParam(2, EmailAddresss);
setWhereClauseParam(3, ContactNumber);
executeQuery();
}
}


Step 10: Save all your work and Run SearchPG


Update the values

Congratulations, you have done it!

3 comments:

  1. Update button works fine, but not updating the data in db

    ReplyDelete
  2. Regards
    Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
    LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b
    Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at training@oracleappstechnical.com | +91 - 9581017828.

    ReplyDelete
  3. apply button in update page not working..

    ReplyDelete