OAF Data Insert Page

Insert Page Creation


1- Create a new Workspace named =TestInsertWS
2- Create a new project   named =TestInsertPR
   Package   =xxaj.TestInsert.oracle.apps.po.webui
3- Create a new AM        named =TestInsertAM
   Package   =xxaj.TestInsert.oracle.apps.po.server
4- Enable Passivation for the Root UI Application Module (AM)



5- Right Click on InsertAM > Edit InsertAM > Custom Properties >

Name – RETENTION_LEVEL
Value – MANAGE_STATE

Click add > Apply > OK


6- 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
);


7- Create a new EO named =TestInsertEO
   package=xxaj.TestInsert.oracle.apps.po.schema.server

8- Create a new VO named =TestInsertVO
   package=xxaj.TestInsert.oracle.apps.po.server

   * In Java page deselect Generate Java file for View Object Class: AdnanVOImpl
     and Select Generate Java File for View Row Class: AdnanVORowImpl

9- Add Your View Object to Root UI Application Module

Right click on TestInsertAM > Edit TestInsertAM > Data Model >

Select TestInsertVO in Available View Objects list and shuttle to Data Model list

10- Create a new Page named TestInsertPG
    Package= xxaj.oracle.apps.po.webui

11- Select region1 and set the following properties:

ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition -- xxaj.TestInsert.oracle.apps.po.server.TestInsertAM
Window Title -- Date Entry Form Window
Title -- Data Entry Form
Auto Footer -- True

12. Right click PageLayoutRN > New > Region

ID -- MainRN
Region Style -- defaultSingleColumn

13. 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 -- AdnanVO1
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 -- AdnanVO1
View Attribute – Column2

14. 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.


15. Implement Row Initialization (Create a View Object Row)

Add createRecord method to your TestInsertAMImpl class

import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
...

    public void createRecord()
    {
      OAViewObject vo = (OAViewObject)getTestInsertVO1();
   
      if (!vo.isPreparedForExecution())
      {
            vo.executeQuery();
      }
   
      Row row = vo.createRow();
      vo.insertRow(row);
      row.setNewRowState(Row.STATUS_INITIALIZED);
    }

16. Create Controller for Page

PageLayoutRN > Set New Controller >

Package Name: xxaj.TestInsert.oracle.apps.po.webui
Class Name: InsertCO


17. 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);
  }
}


18. Add below method in TestInsertAMImpl Class to handle Apply Button action

import oracle.jbo.Transaction;
...

    public void Apply()
    {
      getTransaction().commit();
    }


19. 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("TestInsertVO1");
        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=/xxaj/TestInsert/oracle/apps/po/webui/TestInsertPG",
          null, OAWebBeanConstants.KEEP_MENU_CONTEXT,
          null,
          null,
          true, // retain AM
          OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
 }
}
--------------------------------------------------------------

20- Create Message in oracle applications.


21- Cheers

3 comments: