OAF Update Records

1- Create a search page with the help of following link.

http://oracledot.blogspot.com/p/1-create-new-workspace-matloobsearchws.html

2- Adding Update button on search page created above.

Right click on ResultTable in MatloobSearchPG > New > Item

   Set the following attributes of new item:

   ID                         UpdateAction
   Item Style             image
   Image URI           updateicon_enabled.gif
   Attribute Set        /oracle/apps/fnd/attributesets/Buttons/Update
   Prompt                 Update
   Additional Text    Update record
   Height                   24
   Width                    24
   Action Type          fireAction
   Event                     update
   Submit                   True
   Parameters            Name – PColumn1
                                  Value -- ${oa.MatloobSearchVO1.Column1}
                                  Name – PColumn2
                                  Value -- ${oa.MatloobSearchVO1.Column2}

3- Create a Update Page
Right click on project MatloobSearchPR > New > Web Tier > OA Components > Page
Name – MatloobUpdatePG
Package – MatloobSearch.oracle.apps.po.webui

4- Set the properties of structure of MatloobUpdatePG
    ID -- PageLayoutRN
    Region Style -- PageLayout
    AM Definition -- MatloobSearch.oracle.apps.po.server.MatloobSearchAM
    Window Title -- Update Page Window
    Title -- Update Page
    Auto Footer -- True
5-  Create the Second Region (Main Content Region)
Select PageLayoutRN right click > New > Region
ID – MainRN
Region Style – messageComponentLayout
6- Create first Item (Empty Field)
MainRN > New > messageTextInput
 ID                        - Column1
 Style                    - messageTextInput
 Prompt                - Column1
 DataType            - Varchar2
 Length                 -20
 Max Length        - 100
 View Instance     - MatloobSearchVO1
 View Attribute    - Column1
7- Create first Item (Empty Field)
MainRN > New > messageTextInput
 ID                        - Column2
 Style                    - messageTextInput
 Prompt                - Column2
 DataType            - Varchar2
 Length                 -20
 Max Length        - 100
 View Instance     - MatloobSearchVO1
 View Attribute    - Column2
8- Create a container Region for Apply and Cancel Button in MatloobUpdatePG
Select MainRN of MatloobUpdatePG
MainRN > messageLayout
Region   -  ButtonLayout
9- Create Apply Button
Select ButtonLayout > New > Item
ID                           - Apply
ItemStyle               -  submitButton
Attribute               -  /oracle/apps/fnd/attributesets/Buttons/Apply
10- Create Cancel Button
Select ButtonLayout > New > Item
ID                          -  Cancel
ItemStyle               - submitButton
Attribute               -  /oracle/apps/fnd/attributesets/Buttons/Cancel
11- Add Page Controller for MatloobSearchPG
Right Click on PageLayoutRN of MatloobSearchPG > Set New Controller
Name – MatloobSearchCO
Package -- MatloobSearch.oracle.apps.po.webui
 Add Following code in MatloobSearchCO 

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;

1- Change in process request area. Red colored portion should be added in it.
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processRequest(pageContext, webBean);
 OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");
 queryBean.clearSearchPersistenceCache(pageContext); 

2- Change in processFormRequest area. Red colored portion should be added in it.
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) 

 super.processFormRequest(pageContext, webBean); 
   
 if ("update".equals(pageContext.getParameter(EVENT_PARAM))) 
 { 
  pageContext.setForwardURL("OA.jsp?page=/MatloobSearch/oracle/apps/po/webui/MatloobUpdatePG", 
                                    null, 
                                    OAWebBeanConstants.KEEP_MENU_CONTEXT,                             
                                    null,                                                    
                                    null, 
                                    true,                             
                                    OAWebBeanConstants.ADD_BREAD_CRUMB_NO, 
                                    OAWebBeanConstants.IGNORE_MESSAGES); 
 }
  
}
12- Add Page Controller for MatloobUpdatePG
Right Click on PageLayoutRN of MatloobUpdatePG > Set New Controller
Name – MatloobUpdateCO
Package -- MatloobSearch.oracle.apps.po.webui

Add Following code in Update Page controller MatloobUpdateCO 
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; 
1- Change in process request area. Red colored portion should be added in it.
public void processRequest(OAPageContext pageContext, OAWebBean webBean) 

 super.processRequest(pageContext, webBean); 


 
OAApplicationModule am = pageContext.getApplicationModule(webBean);

 String Column1 = pageContext.getParameter("PColumn1");
 String Column2 = pageContext.getParameter("PColumn2");
 Serializable[] params = { Column1, Column2 };
am.invokeMethod("updateRow", params); 
}
2- Change in processFormRequest area. Red colored portion should be added in it.
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) 

 super.processFormRequest(pageContext, webBean); 
OAApplicationModule am = pageContext.getApplicationModule(webBean); 
       
 if (pageContext.getParameter("Apply") != null) 
 {  
  am.invokeMethod("apply"); 
  pageContext.forwardImmediately("OA.jsp?page=/MatloobSearch/oracle/apps/po/webui/MatloobSearchPG", 
                                         null, 
                                         OAWebBeanConstants.KEEP_MENU_CONTEXT, 
                                         null, 
                                         null, 
                                         false, // retain AM 
                                         OAWebBeanConstants.ADD_BREAD_CRUMB_NO); 
 } 
 else if (pageContext.getParameter("Cancel") != null) 
 {  
  am.invokeMethod("rollback"); 
  pageContext.forwardImmediately("OA.jsp?page=/MatloobSearch/oracle/apps/po/MatloobSearchPG", 
                                         null, 
                                         OAWebBeanConstants.KEEP_MENU_CONTEXT, 
                                         null, 
                                         null, 
                                         false, // retain AM 
                                         OAWebBeanConstants.ADD_BREAD_CRUMB_NO); 
 } 

}
13- Add following Code in MatloobSearchAMImpl

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

  
public void updateRow(String Column1, String Column2)
{
 MatloobSearchVOImpl vo = (MatloobSearchVOImpl)getMatloobSearchVO1();
 vo.initQuery(Column1, Column2);
}
  
public void apply()
{
 getTransaction().commit();
}
public void rollback()
{
 getTransaction().rollback();

14- Add following Code in MatloobSearchVOImpl

import oracle.apps.fnd.framework.server.OAViewObjectImpl;
 
public void initQuery(String Column1, String Column2)
{
 if ((Column1 != null) && (!("".equals(Column1.trim()))))
 {
  setWhereClause("column1 = :1 AND column2 = :2");
  setWhereClauseParams(null); // Always reset
  setWhereClauseParam(0, Column1);
  setWhereClauseParam(1, Column2);
  executeQuery();
 }
}

15- Test & Cheers 

2 comments:

  1. Very well done. Worked just fine.
    Jack

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete