Wednesday, June 15, 2016

Update records in OAF Page

1. Create a Search Page to Create a page please go through the following link

2. Implement Update Action in SearchPG
Right click on ResultTable in SearchPG > New > Item

Set following properties for New Item

Attribute
Property
ID
UpdateAction
Item Style
image
Image URI
updateicon_enabled.gif
Atribute 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.SearchVO1.Column1}
Name – PColumn2
Value -- ${oa.SearchVO1.Column2}

3. Create a Update Page
Right click on SearchDemo > New > Web Tier > OA Components > Page
Name – UpdatePG
Package – search.oracle.apps.PO.searchdemo.webui

4. Select the UpdatePG and go to the strcuture pane where a default region has been created

5. Select region1 and set the following properties:

Attribute
Property
ID
PageLayoutRN
Region Style
PageLayout
AM Definition
search.oracle.apps.PO.searchdemo.server.SearchAM
Window Title
Update Page Window
Title
Update Page
Auto Footer
True

6. Create the Second Region (Main Content Region)
Select PageLayoutRN right click > New > Region
ID – MainRN
Region Style – messageComponentLayout

7. Create first Item (Empty Field)
MainRN > New > messageTextInput

Attribute
Property
ID
Column1
Style Property
messageTextInput
Prompt
Column1
Data Type
VARCHAR2
Length
20
Maximum Length
100
View Instance
SearchVO1
View Attribute
Column1

8. Create second Item (Empty Field)
MainRN > New > messageTextInput

Attribute
Property
ID
Column2
Style Property
messageTextInput
Prompt
Column2
Data Type
VARCHAR2
Length
20
Maximum Length
100
View Instance
SearchVO1
View Attribute
Column2

9. Create a container Region for Apply and Cancel Button in UpdatePG
Select MainRN of UpdatePG
MainRN > messageLayout

Attribute
Property
Region
ButtonLayout

10. Create Apply Button
Select ButtonLayout > New > Item

Attribute
Property
ID
Apply
Item Style
submitButton
Attribute
/oracle/apps/fnd/attributesets/Buttons/Apply

11. Create Cancel Button
Select ButtonLayout > New > Item


Attribute
Property
ID
Cancel
Item Style
submitButton
Attribute
/oracle/apps/fnd/attributesets/Buttons/Cancel


12. Add Page Controller for SearchPG
Right Click on PageLayoutRN of SearchPG > Set New Controller
Name – SearchCO
Package -- search.oracle.apps.PO.searchdemo.webui

Add Following code in Search Page controller SearchCO 


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;
public class SearchCO extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    
    OAQueryBean QB=(OAQueryBean)webBean.findChildRecursive("QueryRN");
    QB.clearSearchPersistenceCache(pageContext);
    
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    if("update".equals(pageContext.getParameter(EVENT_PARAM)))
    {
      pageContext.setForwardURL("OA.jsp?page=/search/oracle/apps/PO/searchdemoPRJ/webui/updatePG", 
                                          null, 
                                          OAWebBeanConstants.KEEP_MENU_CONTEXT,                             
                                          null,                                                    
                                          null, 
                                          true,                             
                                          OAWebBeanConstants.ADD_BREAD_CRUMB_NO, 
                                          OAWebBeanConstants.IGNORE_MESSAGES); 
    }
  }

}
13. Add Page Controller for UpdatePG
Right Click on PageLayoutRN of UpdatePG > Set New Controller
Name – UpdateCO
Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

Add Following code in Update Page controller UpdateCO 

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; 
public class UpdateCO extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  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); 
    }


  

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    searchAMImpl am=(searchAMImpl)pageContext.getApplicationModule(webBean);
          
    if (pageContext.getParameter("Apply") != null) 
    {  
     am.invokeMethod("apply"); 
     
    pageContext.forwardImmediately("OA.jsp?page=/search/oracle/apps/PO/searchdemoPRJ/webui/searchPG", 
                                               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=/search/oracle/apps/PO/searchdemoPRJ/webui/searchPG", 
                                            null, 
                                            OAWebBeanConstants.KEEP_MENU_CONTEXT, 
                                            null, 
                                            null, 
                                            false, // retain AM 
                                            OAWebBeanConstants.ADD_BREAD_CRUMB_NO); 
    } 
    }
  }

14. Add following Code in SearchAMImpl
   public void apply() 
  { 
   getOADBTransaction().commit(); 
  }

  public void rollback() 
  { 
   getOADBTransaction().rollback(); 
  }
  public void updateRow(String Column1, String Column2) 
  { 
   searchVOImpl vo = (searchVOImpl)getsearchVO1(); 
   vo.initQuery(Column1,Column2);
  } 
15. Add following Code in SearchVOImpl

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(); 
   } 
  }

16. Congratulation you have successfully finished. Run Your Search page and Test Your Work

(1)
(2)
(3)

(4)

End





No comments:

Post a Comment