Create and Update on one click in OA Framework

 

We will try to implement Search Page with one text item as ID. Based on ID control will go to second page. Second page contain three text rows. ID will be displayed on second page as Styled Text in all three rows

If match will be found based on ID then search result will come. If not found then empty rows will come. Based on that new data can be inserted there and existing data can be updated directly with one button click ‘Apply’ 

 

1. Create a New Workspace and Project

Right click Workspaces and click create new OAworkspace.

File Name – PrajkumarSearch

Project Name -- SearchDemo

package -- prajkumar.oracle.apps.fnd.searchdemo

 

2. Create a New Application Module (AM)

Right Click on SearchDemo > New > ADF Business Components > Application Module

Name -- SearchAM

Package -- prajkumar.oracle.apps.fnd.searchdemo.server

 

3. Enable Passivation for the Root UI Application Module (AM)

Right Click on SearchAM > Edit SearchAM > Custom Properties >

Name – RETENTION_LEVEL

Value – MANAGE_STATE

Click add > Apply > OK

 

4. Create Test Table and insert data some data in it (For Testing Purpose)

CREATE TABLE xx_create_upd_demo
(    -- ---------------------
     -- Data Columns
     -- ----------------------
     column1                  VARCHAR2(100),
     column2                  VARCHAR2(100),
     column3                  VARCHAR2(100), 
     column4                  NUMBER,
      -- ---------------------
      -- Who Columns
      -- ---------------------
      last_update_date   DATE           NOT NULL,
      last_updated_by    NUMBER     NOT NULL,
      creation_date         DATE           NOT NULL,
      created_by             NUMBER      NOT NULL,
      last_update_login  NUMBER
);

 

5. Create a New Entity Object (EO)

Right click on SearchDemo > New > ADF Business Components > Entity Object

Name – SearchEO

Package -- prajkumar.oracle.apps.fnd.searchdemo.schema.server

Database Objects -- xx_create_upd_demo

 

Note – By default ROWID will be the primary key if we will not make any column to be primary key.

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

 

6. Create a New View Object (VO)

Right click on SearchDemo > New > ADF Business Components > View Object

Name -- SearchVO

Package -- prajkumar.oracle.apps.fnd.searchdemo.server

In Step2 in Entity Page select SearchEO and shuttle them to selected list

In Step3 in Attributes Window select columns Column1, Column2, Column3, Column4 and shuttle them to selected list

In Java page select Generate Java File for View Object Class: SearchVOImpl and Generate Java File for View Row Class: SearchVORowImpl

 

7. Add Your View Object to Root UI Application Module

Select Right click on SearchAM > Application Modules > Data Model >

Select SearchVO and shuttle to Data Model list

 

8. Create a New Page

Right click on SearchDemo > New > Web Tier > OA Components > Page

Name -- SearchPG

Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

 

9. Select the SearchPG and go to the strcuture pane where a default region has been created

 

10. Select region1 and set the following properties:

ID – PageLayoutRN

Scope -- Public

Region Style -- PageLayout

AM Definition -- prajkumar.oracle.apps.fnd.searchdemo.server.SearchAM

Window Title –Page Window

Title – Page Header

Auto Footer – True

 

11. Create the Second Region (Main Content Region)

ID – MainRN

Region Style -- messageComponentLayout

Auto Footer – True

 

12. Create the first Item (Empty Field)

MainRN > New > messageTextInput

Set Following properties for new item

ID – MyId

Style Property – messageTextInput

Prompt – Id

Data Type – Number

Length – 20

Maximum Length – 100

 

13. Create a container Region for Go-Button

MainRN > messageLayout

Set ID -- ButtonLayout

 

14. Create a Item (Go Button)

Select ButtonLayout > New > Item

ID – Go

Item Style – submitButton

Attribute -- /oracle/apps/fnd/attributesets/Buttons/Go

 

15. Create a New Second Page

Right click on SearchDemo > New > Web Tier > OA Components > Page

Name -- CreateUpdPG

Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

 

16. Select the CreateUpdPG and go to the strcuture pane where a default region has been created

 

17. Select region1 and set the following properties:

ID – PageLayoutRN

Scope -- Public

Region Style -- PageLayout

AM Definition -- prajkumar.oracle.apps.fnd.searchdemo.server.SearchAM

Window Title –Page Window

Title – Page Header

Auto Footer – True

 

18. Create the Second Region (Main Content Region)

ID – MainRN

Region Style -- table

Auto Footer – True

Records Displayed – 3

 

19. Create the first Item (Empty Field)

MainRN > New > item

Set Following properties for new item

ID – Column1

Style Property – messageTextInput

Prompt – Column1

Data Type – VARCHAR2

Length – 20

Maximum Length – 100

View Instance -- SearchVO1

View Attribute -- Column1

 

Create Second Item

MainRN > New > item

Set Following properties for new item

ID – Column2

Style Property – messageTextInput

Prompt – Column2

Data Type – VARCHAR2

Length – 20

Maximum Length – 100

View Instance -- SearchVO1

View Attribute -- Column2

 

Create Third Item

MainRN > New > item

Set Following properties for new item

ID – Column3

Style Property – messageTextInput

Prompt – Column3

Data Type – VARCHAR2

Length – 20

Maximum Length – 100

View Instance -- SearchVO1

View Attribute -- Column3

 

Create Fourth Item

MainRN > New > item

Set Following properties for new item

ID – Column4

Style Property – messageStyledText

Prompt – Column4

Data Type – NUMBER

View Instance -- SearchVO1

View Attribute -- Column4

 

20. Add Controller for Page SearchPG Select PageLayoutRN right click Set New Controller

Package Name -- prajkumar.oracle.apps.fnd.searchdemo.webui

Class Name -- SearchCO

Add Following code in that controller

 
import com.sun.java.util.collections.HashMap;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
 
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
  super.processFormRequest(pageContext, webBean);
  if (pageContext.getParameter("Go") != null)
  {
   String userContent = pageContext.getParameter("MyId");
   HashMap hmap = new HashMap();
   hmap.put("MyId", userContent);
   
   pageContext.setForwardURL(
       "OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/webui/CreateUpdPG",
       null,                            
       OAWebBeanConstants.KEEP_MENU_CONTEXT,                                                   
       null,                                                   
       hmap,                            
       true,
       OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
    OAWebBeanConstants.IGNORE_MESSAGES); 
}
}
 
 
21. Add Return Link to come back to SearchPG from CreateUpdPG
Select CreateUpdPG in Structure Panel Select PageLayoutRN > New > returnNavigation
ID – ReturnLink
Destination URI – OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/webui/SearchPG&retainAM=Y
Text – Return to SearchPG
 
22. Add pageButtonBar region to implement Apply Button
Right click on PageLayout > New > Region
Set following properties for new region
ID -- ButtonBar
Region Style – pageButtonBar
Select ButtonBar right click > New > Item
Select newly created item and set following properties –
ID – Apply
Item Style – submitButton
Attribute Set -- /oracle/apps/fnd/attributesets/Buttons/Apply
 
23. Add Controller for Page CreateUpdPG Select PageLayoutRN right click Set New Controller
Package Name -- prajkumar.oracle.apps.fnd.searchdemo.webui
Class Name -- CreateUpdCO
Add Following code in that controller
 
import java.io.Serializable;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{  super.processRequest(pageContext, webBean);
   OAApplicationModule am = pageContext.getApplicationModule(webBean);
 
  String val = pageContext.getParameter("MyId");
 
  Serializable[] params = { val };
  am.invokeMethod("createRow", params);              
}
 
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{  super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
 
  if (pageContext.getParameter("Apply") != null)
  {  am.getTransaction().commit();
pageContext.setForwardURL(
  "OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/webui/SearchPG",
         null,        
         OAWebBeanConstants.KEEP_MENU_CONTEXT,        
         null,        
         null,        
         true,        
         OAWebBeanConstants.ADD_BREAD_CRUMB_NO,        
         OAWebBeanConstants.IGNORE_MESSAGES);   
    }
}
 
24. Add Following code in SearchAMImpl.java
 
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.Row;
public void createRow(String Val)
{
  SearchVOImpl vo = getSearchVO1();
  vo.initQuery(Val);
 
  int rowCount = vo.getRowCount();
  if ( rowCount < 3 )
  {
   for(int i = 3; i != rowCount ; rowCount++)
   {
           Row studrow = vo.createRow();
    vo.last();
    vo.next();
                
    vo.insertRow(studrow);
    vo.setCurrentRow(studrow);
    vo.getCurrentRow().setAttribute("Column4",Val);
    studrow.setNewRowState(Row.STATUS_INITIALIZED);
   }
  }
}
 
25. Add Following code in SearchVOImpl.java
 
import oracle.jbo.domain.Number;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
public void initQuery(String Val)
{
  if ((Val != null) && (!("".equals(Val.trim()))))
  {
   // Do the following conversion for type consistency.
   Number Val2 = null;
                     
   try
   {
    Val2 = new Number(Val);
   }
   catch(Exception e)
   {
    throw new OAException("AK", "FWK_TBX_INVALID_EMP_NUMBER");
   }
                           
   setWhereClause("Column4 = :1");
   setWhereClauseParams(null); // Always reset
   setWhereClauseParam(0, Val2);
   executeQuery();
}
}
 
26. Congratulation you have successfully finished. Run Your SearcgPG page and Test Your Work
 
 
 
 
 
 
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Welcome to My Oracle World Puneet Rajkumar

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today