Update records in OAF Page

Posted by PRajkumar on Oracle Blogs See other posts from Oracle Blogs or by PRajkumar
Published on Wed, 27 Jun 2012 13:35:11 +0000 Indexed on 2012/06/27 15:21 UTC
Read the original article Hit count: 496

Filed under:

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

https://blogs.oracle.com/prajkumar/entry/create_oaf_search_page

 

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 – prajkumar.oracle.apps.fnd.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

prajkumar.oracle.apps.fnd.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 -- prajkumar.oracle.apps.fnd.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 void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processRequest(pageContext, webBean);

 OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");
 queryBean.clearSearchPersistenceCache(pageContext);
}
 
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processFormRequest(pageContext, webBean);
  
 if ("update".equals(pageContext.getParameter(EVENT_PARAM)))
 {
  pageContext.setForwardURL("OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/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 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);
}

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=/prajkumar/oracle/apps/fnd/searchdemo/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=/prajkumar/oracle/apps/fnd/searchdemo/webui/SearchPG",
                                         null,
                                         OAWebBeanConstants.KEEP_MENU_CONTEXT,
                                         null,
                                         null,
                                         false, // retain AM
                                         OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
 }
}

 

14. Add following Code in SearchAMImpl

 

import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
   
public void updateRow(String Column1, String Column2)
{
 SearchVOImpl vo = (SearchVOImpl)getSearchVO1();
 vo.initQuery(Column1, Column2);
}
   
public void apply()
{
 getTransaction().commit();
}

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

 

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

 

 

 

 

 

 

 

 

 

 

 

 

 

© Oracle Blogs or respective owner

Related posts about /Oracle