Wednesday 11 July 2018

event_param in oaf


event_param in oaf

Event_Param helps to capture the event generated by a webbean in the oaf Page. Web bean could be messageinputtext or messageStyleText, or messageLovInput or table in the oaf page. With the help of EVENT_PARAM we can identify the generated event in the OAF and then write the code according to that as per the Webbean event generated.
Here in this Example ,I am sharing the Business Requirment and the use of Event_Param to write the Custom code to meet the business Requirment.
Business Requirment is , Sometime to implement Business Logic we need to put validations. On the basis of validation we Enable Disable fields. We  can do this by partial rendering Feature. In this topic I trying to implement this.
 
 
Right Click on Applications. Click New OA Workspace.
Enter the Workspace Name=RohitPartialRendring.
 
 
event_param in oaf

Enter the Workspace Name=RohitPartialRendring.
event_param in oaf

Project Wizard will open.Click Next.
event_param in oaf
Enter the Project Related Properties.
Enter the Project Name=RohitPartialRendring
Default Package=rohit.oracle.apps.fnd.RohitPartialRendring
event_param in oaf
Enter the RunTime connection details as below.Enter the E-business Suit Application User Name and Password.(already explained in the JDev installation).

Workspace and project has been created.


Now we create Application Module.
Right click on Project “RohitPartialRendring”.Click New.

Select Application Module.Click OK 
event_param in oaf

 
Enter the Application Module Properties.
Application Module Name= RohitPartialRendringAM
Default Package=rohit.oracle.apps.fnd.RohitPartialRendring.server
Click Next and then finish.

 

event_param in oaf

 

Now we create OAF Page.
Right  Click On Project “RohitPartialRendring”.Click New.

Under the OA Components.Select “Page” and then ok.

event_param in oaf


 
Enter the Page Proeprties.
Page Name= RohitPartialRendringPG.
Defualt Package=rohit.oracle.apps.fnd. RohitPartialRendring.webui

event_param in oaf


Page has Created as Below :-

 
Select the “RohitPartialRendringPG”.Under the Structure Pane.Select the “region1” and then in the property window for this region change the Region ID=”PageLayoutRN”.

ID=”PageLayoutRN”.

Now we have to set the Application Module for the PageLayoutRN.
Set AM Property for “PageLayoutRN”.
AM=rohit.oracle.apps.fnd.RohitPartialRendring.server.RohitPartialRendringAM.

Now we create a new Region under the “PageLayoutRN”.
Right Click on “PageLayoutRN”.Click New an then Click Region.


Then Region1 has created.Change the Name(ID) of Region1 in Property window with “MainRN”.
ID=MainRN

Right Click On “MainRN”.Click New and then Click messagetextinput.
Item1 has created under MainRN.
 


Same like above create item2,item3,item4.
After this Change properties of item1,item2,item3,item4 in the property window.



For Item1
ID=FirstName
Prompt=First Name.
For Item2
ID=LastName
Prompt=Last Name.
For Item3
ID=Male
Prompt=Male.
Item Style=messagecheckbox.
For Item4
ID=Female.
Prompt=Female.
Item Style=messagecheckbox.


After this Again Right Click on Region MainRN. And then create two messagetextinput as like above.
Item1 and item2 has created after this.



Now we have to make a condition when the user click “Male”CheckBox then item1 display and item2 has hide. And when the user click “FEMALE” then item2 display and item1 has hide.
For this we have set “Action type” Property for Male and Female CheckBox in the property window as below.


Click on Male CheckBox. And then go to property window.
Change Proeprties as below


Action Type=firePartialAction
Event=action1






The property which we have set for Male checkbox the same property we have to set for Female checkbox
Click on Female checkbox
Go to property window for Female Check Box.

Female CheckBox Proeprties
Action Type=firePartialAction.
Event=action2 


 
Now we have to create view Object to implement partial rendring.
Right Click on Project “RohitPartialRendring”.Click New.



Enter the View Object Properties.
Veiw Object Name= RohitPartialRendringVO
Default Package=rohit.oracle.apps.fnd.RohitPartialRendringVO.server

Click Next and then go to step3 in below screen.Click New Button.
 Click New Button.


Enter the View Object Attribute Property as like in below screen
Name=RowKey
Type=Number.
Updatable=Click OK.
As like Below Sceen

After creating “RowKey” Attribute for View Object.Again Click New Button and create 2nd Attribute
2nd Attribute Property.
Name=DummyAttr.
Type=Boolean.
Updateable Always.
 
3rd Attribute Property.
Name=DummyAttr2.
Type=Boolean.
Updateable Always.


Now we have write a logic to implement “Partial Rendring”.We have to create a new controller for this.
Right Click on the the “PageLayoutRN”.Click Set new Controller.




Now we have write a logic to implement “Partial Rendring”.We have to create a new controller for this.
Right Click on the the “PageLayoutRN”.Click Set new Controller.



Enter the Controller Properties.
Controller Name=RohitPartialRendringCO.
Default Package=rohit.oracle.apps.fnd.RohitPartialRendring.webui

We have to display item1 and item2 dynamically based on click on Male Female check box
So we have to set “Rendered” Property for “item1” and “item2”.
Click on item1 and then go to property window.
Set item1 Properties
item1 rendered property= ${oa.RohitPartialRendringVO.DummyAttr}.



Click on item2 and then go to property window.
Set item2 Properties
item2 rendered property= ${oa.RohitPartialRendringVO.DummyAttr2}



Now we will attach the view object “RohitPartialRendringVO” with Application Module “RohitPartialRendringAM”.


Right Click on Application Module “RohitPartialRendringAM”.Click “Edit RohitPartialRendringAM”.


Click next and then finish.

Now our coding Part will be start. So First we will create method under the RohitPartialRendringAMIMPL.java class.

Here is the Code.



public void handlePPRAction() 
  {
    Number val1=1;
    OAViewObject vo=(OAViewObject)findViewObject("RohitPartialRendringVO");
    
     if(vo!=null)
     {
      
       if (vo.getFetchedRowCount()==0)
       {
         vo.setMaxFetchSize(0);
         vo.executeQuery();
         vo.insertRow(vo.createRow());
        
        OARow row=(OARow)vo.first();
        row.setAttribute("RowKey", val1);
        row.setAttribute("DummyAttr",Boolean.TRUE);
         row.setAttribute("DummyAttr2",Boolean.TRUE);
       
       
       }
      
     }
  }
 
Double click on the Controler name "RohitPartialRendringCO".

Put the code under the Process Form Request Block.


 public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
   
    OAApplicationModule am=(OAApplicationModule)pageContext.getApplicationModule(webBean);
    am.invokeMethod("handlePPRAction");
   
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am=(OAApplicationModule)pageContext.getApplicationModule(webBean);
   
    OAViewObject vo=(OAViewObject)am.findViewObject("RohitPartialRendringVO");
   
    OARow row=(OARow)vo.getCurrentRow();
   
    if ("action1".equals(pageContext.getParameter(EVENT_PARAM)))
    {
     
      row.setAttribute("DummyAttr",Boolean.TRUE);
       row.setAttribute("DummyAttr2",Boolean.FALSE);
    }
   
   

    if ("action2".equals(pageContext.getParameter(EVENT_PARAM)))
    {
     
      row.setAttribute("DummyAttr",Boolean.FALSE);
       row.setAttribute("DummyAttr2",Boolean.TRUE);
    }

   
   
  }


Now Right click on Project"RohitPartialRendring" and click on "Rebuid" .

Now again Right click on Project"RohitPartialRendring" and click on "Run" .






OutPut:-

 

0 comments:

Post a Comment

Contact us for any Collaboration, Project Support & On Job Support Work

Name

Email *

Message *