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!

Tuesday, January 6, 2015

Search Page in OAF

Pre-Requisite

i.                     Table Creation Script

CREATE TABLE XX_OAF_DEMO_STG
(
   record_id           NUMBER,
   person_type         VARCHAR2 (100),
   person_name         VARCHAR2 (200),
   email_addresss      VARCHAR2 (100),
   contact_number      VARCHAR2 (100),
   last_update_date    DATE,
   last_updated_by     NUMBER,
   creation_date       DATE,
   created_by          NUMBER,
   last_update_login   NUMBER
);

ii.                   Insert Statements

INSERT INTO xx_oaf_demo_stg (record_id,
                             person_type,
                             person_name,
                             email_addresss,
                             contact_number,
                             last_update_date,
                             last_updated_by,
                             creation_date,
                             created_by,
                             last_update_login)
     VALUES (1,
             'Customer',
             'ABC Customer',
             'info@abc.com',
             '100-200-300',
             SYSDATE,
             -1,
             SYSDATE,
             -1,
             -1);


INSERT INTO xx_oaf_demo_stg (record_id,
                             person_type,
                             person_name,
                             email_addresss,
                             contact_number,
                             last_update_date,
                             last_updated_by,
                             creation_date,
                             created_by,
                             last_update_login)
     VALUES (2,
             'Customer',
             'XYZ Customer',
             'info@xyz.com',
             '200-200-300',
             SYSDATE,
             -1,
             SYSDATE,
             -1,
             -1);

INSERT INTO xx_oaf_demo_stg (record_id,
                             person_type,
                             person_name,
                             email_addresss,
                             contact_number,
                             last_update_date,
                             last_updated_by,
                             creation_date,
                             created_by,
                             last_update_login)
     VALUES (3,
             'Supplier',
             'ABC Supplier',
             'info@abcs.com',
             '100-300-300',
             SYSDATE,
             -1,
             SYSDATE,
             -1,
             -1);

INSERT INTO xx_oaf_demo_stg (record_id,
                             person_type,
                             person_name,
                             email_addresss,
                             contact_number,
                             last_update_date,
                             last_updated_by,
                             creation_date,
                             created_by,
                             last_update_login)
     VALUES (4,
             'Supplier',
             'XYZ Supplier',
             'info@xyzs.com',
             '100-300-400',
             SYSDATE,
             -1,
             SYSDATE,
             -1,
             -1);


 Step 1:  Create a New Work space and Project



Step 2:  Create a New Entity Object


Right click on SearchWS -> Business Tier -> Entity Object


Name
SearchEO
Package
oracle.apps.fnd.searchproj.server
Schema Object
XX_OAF_DEMO_STG



Check the Accessors, Create Method, Validation Method and Remove Method

Step 3:  Create a New View Object (VO)


Select SearchEO


In Java page deselect Generate Java file for View Object Class: SearchVOImpl and Select Generate Java File for View Row Class: SearchVORowImpl

Step 4:  Attach View Object (VO) to Application Module (AM)


Step 5:  Create a New OA Page


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



Step 6:  Create a New Query Region


Update the properties

ID
QueryRN
Region Style
query
Construction Mode
autoCustomizeCriteria


Step 7: Create a New table (Query) Region 

Application Module
oracle.apps.fnd.searchproj.server.SearchAM
Available View Usages
SearchVO


Region ID
SearchTable
Region Style
table



Change Style with “messageStyledText”

Update Width -> 100%

Step 8: Create a Simple Search Panel

ID
SearchHeaderRN
Region Style
messageComponentLayout

Step 9: Create a Simple Search Panel Input Fields

ID
SearchPersonType
Region Style
messageTextInput
Search Allowed
True
Prompt
Person Type
CSC Class
OraFieldText


ID
SearchPersonName
Region Style
messageTextInput
Search Allowed
True
Prompt
Person Name
CSC Class
OraFieldText


Step 10: Create a Simple Search Query Mappings

ID
SearchPersonTypeMap
Search Item
SearchPersonType
Results Item
PersonType


Add a New Query Map

ID
SearchPersonNameMap
Search Item
SearchPersonName
Results Item
PersonName


Step 11: Save all your work and Run SearchPG.xml



Congratulations, you have done it!