Create Data Entry OAF Page


Create Data Entry OAF Page


1. Create a New Workspace and Project
Right click Workspaces and click create new OAworkspace and name it as PRajkumarInsert. Automatically a new OA Project is also created. Name the project as InsertDemo and package as prajkumar.oracle.apps.fnd.insertdemo

2. Create a New Application Module (AM)
Right Click on InsertDemo > New > ADF Business Components > Application Module
Name -- InsertAM
Package -- prajkumar.oracle.apps.fnd.insertdemo.server

3. Enable Passivation for the Root UI Application Module (AM)
Right Click on InsertAM > Edit InsertAM > Custom Properties >
Name – RETENTION_LEVEL
Value – MANAGE_STATE
Click add > Apply > OK

4. Create Test Table in which we will insert data (For Testing Purpose)
CREATE TABLE xx_insert_demo
(        -- --------------------- 
         -- Data Columns  
         -- --------------------- 
         column1                           VARCHAR2(100), 
         column2                           VARCHAR2(100), 
         -- ---------------------             
         -- 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 InsertDemo > New > ADF Business Components > Entity Object
Name – InsertEO
Package -- prajkumar.oracle.apps.fnd.insertdemo.schema.server
Database Objects -- XX_INSERT_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 InsertDemo > New > ADF Business Components > View Object
Name -- InsertVO
Package -- prajkumar.oracle.apps.fnd.insertdemo.server
In Step2 in Entity Page select InsertEO and shuttle them to selected list
In Step3 in Attributes Window select columns Column1, Column2 and shuttle them to selected list
In Java page deselect Generate Java file for View Object Class: InsertVOImpl and Select Generate Java File for View Row Class: InsertVORowImpl

7. Add Your View Object to Root UI Application Module
Right click on InsertAM > Edit InsertAM > Data Model >
Select InsertVO in Available View Objects list and shuttle to Data Model list

8. Create a New Page
Right click on InsertDemo > New > Web Tier > OA Components > Page
Name -- InsertPG
Package -- prajkumar.oracle.apps.fnd.insertdemo.webui

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

10. Select region1 and set the following properties:
ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition -- prajkumar.oracle.apps.fnd.insertdemo.server.InsertAM
Window Title -- Date Entry Page Window
Title -- Data Entry Page
Auto Footer -- True

11. Right click PageLayoutRN > New > Region
ID -- MainRN
Region Style -- defaultSingleColumn

12. Create Text Input Items
Right click on MainRN > New > Item
Set following properties for New Item
ID -- COLUMN1
Item Style -- messageTextInput
Maximum Length -- 100
Length -- 20
Prompt -- Column1
View Instance -- InsertVO1
View Attribute -- Column1

Again Right click on MainRN > New > Item
Set following properties for New Item 
ID -- COLUMN2
Item Style -- messageTextInput
Maximum Length -- 100
Length -- 20
Prompt -- Column2
View Instance -- InsertVO1
View Attribute – Column2

13. Add Apply and Cancel Buttons
Right click on PageLayoutRN > New > Region
         ID -- PageButtons
         Region Style -- pageButtonBar

Right click on PageButtons > New > Item
ID -- Cancel
Item Style -- submitButton
Attribute Set -- /oracle/apps/fnd/attributesets/Buttons/Cancel
Disable Server Side Validation -- True
Prompt -- Cancel
Warm About Changes -- False
Additional Text – Select to cancel this transaction.

Right click on PageButtons > New > Item
ID -- Apply
Item Style -- submitButton
Attribute Set -- /oracle/apps/fnd/attributesets/Buttons/Apply
Prompt -- Apply
Additional Text – Select to save this transaction.

14. Implement Row Initialization (Create a View Object Row)
Add createRecord method to your InsertAMImpl class
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
...
  
public void createRecord()
{
  OAViewObject vo = (OAViewObject)getInsertVO1();
 
  if (!vo.isPreparedForExecution()) 
  { 
 vo.executeQuery(); 
  }
 
  Row row = vo.createRow();
  vo.insertRow(row);
  row.setNewRowState(Row.STATUS_INITIALIZED);
} 
 
15. Create Controller for Page  
PageLayoutRN > Set New Controller >
Package Name: prajkumar.oracle.apps.fnd.insertdemo.webui
Class Name: InsertCO

16. Add Create Page Initialization to your Controller
Add following code to your processRequest()
import oracle.apps.fnd.framework.OAApplicationModule;
...
 
public void processRequest(OAPageContext pageContext,OAWebBean webBean)
{
  super.processRequest(pageContext, webBean);  
 
  if (!pageContext.isFormSubmission())
  {
   OAApplicationModule am = pageContext.getApplicationModule(webBean);
   am.invokeMethod("createRecord", null);
  }  
}

 

17. Add below method in InsertAMImpl Class to handle Apply Button action
import oracle.jbo.Transaction;
...
 
public void apply()
{
  getTransaction().commit();
}

 
18. Add below Logic in InsertCO to handle Apply Button
Add following code to your processFormRequest()
import oracle.jbo.domain.Number; 
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
...

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{super.processFormRequest(pageContext, webBean);
 OAApplicationModule am = pageContext.getApplicationModule(webBean);
 // Pressing the "Apply" button means the transaction should be
 // validated and committed.
              
 if (pageContext.getParameter("Apply") != null) 
 {
  OAViewObject vo = (OAViewObject)am.findViewObject("InsertVO1");
  String column1 = (String)vo.getCurrentRow().getAttribute("Column1");
  String column2 = (String)vo.getCurrentRow().getAttribute("Column2");
                     
  am.invokeMethod("apply");
                     
  // Create a FND Message with name "TEST_CREATE_CONFIRM" with two 
  // tokens                   
  MessageToken[] tokens = { new MessageToken("COLUMN1", column1),
                            new MessageToken("COLUMN2", column2) 
                          };
 
  OAException confirmMessage = new OAException( "FND",
                                 "TEST_CREATE_CONFIRM", tokens,
                                 OAException.CONFIRMATION, null);
   
  pageContext.putDialogMessage(confirmMessage);
  pageContext.forwardImmediately(
   "OA.jsp?page=/prajkumar/oracle/apps/fnd/insertdemo/webui/InsertPG",
    null, OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    null,
    true, // retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
 }
}
 
 

19. Congratulations you have successfully created data insert page. Run InsertPG page to test Your Work











No comments:

Post a Comment

How to find all cancel Requisitions

SELECT prha . *   FROM po_Requisition_headers_all prha , po_action_history pah   WHERE      1 = 1        AND pah . object_id ...