Showing posts with label Controller Extension. Show all posts
Showing posts with label Controller Extension. Show all posts

Friday, 23 March 2018

Controller Extension In OAF :How to add OAF code in Controller Extension on Button Click Event

Part1 Controller Extension In OAF :How to add code in Controller Extension on Button Click Event

 
We will do today controller Extension in Oracle Application OAF pages. We need Controller Extension when we want to add custom Validations and to add extra monitoring in the Standard process or to Control the Standard Page behavior  then we do Controller Extensions to achieved this requirement. We can control the functionality of the Page through Controller codes and if we want to control the Standard OAF pages then we do OAF Controller Extensions.
 
Test Case:- In this example , I will do Controller Extension in the Expense Reports Home Page. Suppose your Business requirement is  that When ever user will withdraw his expense report then it will create history in the Custom table that how many times this particular Expense Report's  Withdraw and on which date. So lets start to do this.
 

Controller Extension In OAF :How to add code in Controller Extension on Button Click Event

 
Step1:- First Go to your OAF page in the application , in which you will Controller Extension.
This is the Page in which we will do Controller Extension. you can see the Withdraw button in the Right side of the Page for Every Report.
 
Controller Extension In OAF :How to add OAF code in Controller Extension on Button Click Event
 
 
Step2:- To see the Properties of this Page and to know which controller is working behind this Page. for this we need to go to 'About this Page' in the Bottom of the Page.
 
 
 
Step3:- Click on the Expand All option and in the Controller Section you can see the Controller Name.
 
Controller Extension In OAF :How to add OAF code in Controller Extension on Button Click Event
 
 
 

Step4:- Now you know the Controller Name but you also need to get  the Location of the Controller in Oracle Application to so Controller Extension.


Step by Step to do Controller Extension

This is the Location of the Controller under Java_Top under which you will do Extension.
OAF Extension Guide

Step5:- Now you get to know that where is your Standard Controller is Placed in the Oracle application Under Java_Top.

Then you Need to go to Server Under Java_Top then Under Java_Top follow the same path 'oracle/apps/ap/oie/webui/' and copy the 'TrackExpesneReportsCO' from Server to your Local Desktop.

One Important Thing.

You need to create the same path in your JDev folder under' 'jdevhome'
Under JdevHome there is MyProjects' folder under this folder you have to Create same folder structure like oracle/apps/ap/oie/webui/' and then this copied file 'TrackExpesneReportsCO' in this Location.

The rule is you have to create same folder structure like the Folder Structure created for The Standard Controller in the Application server Java_Top.

 
 
 
Step6:-This is the steps you have to implement before doing Start Extension in the JDeveloper.
 
Step7:- Now open the JDeveloper.
 
 
 
 
 
Step8:- Now we will create OA Workspace and Project to do Controller Extensions.
 

 
Step9:- Give the Name of OA Workspace. Click Ok.
 
 
Step10:- Now Give the Name of the Project same like OA workspace.
Package Path:- Choose the same like Standard Controller but choose the application Top start with xx like this this change 'xxap'.
 

Step11:- Then Finish this Project.
Controller Extension In OAF :How to add OAF code in Controller Extension on Button Click Event

Step12:- Now you can see your OAF Project has been completed. Now we will do Controller Extension under this Project.
 Due to the Length of this Topic , I will split this Topic two Posts. Please find the Second Part of this Post as below

Part2 url:- https://rpforacle.blogspot.in/2018/03/oaf-controller-extension-in-oaf-how-to-add-oaf-code-in-controller-extension-on-button-click-event.html


 

Thursday, 22 March 2018

How to Execute and Fetch SQL Queries Data Rows in OAF

How to Execute and Fetch SQL Queries Data in OAF

 
Hi Friends , In this post I will show the OAF code to Execute the Sql query in the OAF controller and then Fetch all the rows of this queries in the Same controller to do further Analysis. We often need to user SQL queries in OAF code to do data comparison and to get the values from other modules so using this OAF code will help you allot in you OAF controller Extension to execute and fetch all the rows of the Sql query.
 

How to Execute and Fetch SQL Queries rows in OAF

 
Step1:- Suppose you are doing Controller Extension in your PR approval Notification Page and in your PR you have maintained some values in DFF of 'PO_REQUISITION_LINES_ALL' and here in CO extension you want to fetch these values.
 
 
Step2:-  This is the OAF code to execute and Fetch Sql query results in OAF controller and then can be used for Comparison.
 
 
 public void processRequest(OAPageContext paramOAPageContext, OAWebBean paramOAWebBean)
    {
      paramOAPageContext.writeDiagnostics(this, "XX Start PR ", 1);
     
        String parameterName;
        String COL1_VALUE="";    
        String COL2_VALUE=""; 
        String COL3_VALUE="";    
       
       Number PRHdrId;
            PRHdrId = new Number(paramOAPageContext.getDecryptedParameter("PRHeaderId"));
                if (PRHdrId!=null)
                {
        
    Connection conn = paramOAPageContext.getApplicationModule(paramOAWebBean).getOADBTransaction().getJdbcConnection();
     String Query = "SELECT attribute1 col1,attribute2 col2,attribute3 col3 FROM PO_REQUISITION_LINES_ALL WHERE REQUISITION_HEADER_ID=TO_NUMBER(:1)";

                PreparedStatement stmt = conn.prepareStatement(Query);
                   String PRHdrId = ""+PRHdrId;
                   
     stmt.setString(1,PRHdrId);
     for(ResultSet resultset = stmt.executeQuery(); resultset.next();)
     {
  
   COL1_VALUE = resultset.getString("COL1");
                       COL2_VALUE = resultset.getString("COL2");
                       COL3_VALUE = resultset.getString("COL3");
      paramOAPageContext.writeDiagnostics(this, "Query executed"+COL1_VALUE,1);
                   paramOAPageContext.writeDiagnostics(this, "Query executed"+COL1_VALUE,1);
                   paramOAPageContext.writeDiagnostics(this, "Query executed"+COL1_VALUE,1);
     }
  
 
 
Result Set :-
 
A table of data representing a database result set, which is usually generated by executing a statement that queries the database.
A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.
 
 
 
How to Execute and Fetch SQL Queries Data Rows in OAF
 
 
How to Execute and Fetch SQL Queries Data Rows in OAF

Wednesday, 21 March 2018

How To Get the LOV Selection Event in OAF Controller For CO Extension

How To Get the LOV Selection Event in OAF Controller For CO Extension

We often need in OAF Controller Extensions to get the Events from the Page to Execute our Custom Code. Suppose If we want to Execute or want to Change some values in the OAF page when the user will select the LOV from the OAF page. For this We can use this below code to Find the LOV Selection Event in the OAF controller and write our custom code inside that Event for Controller(CO) Extension.
 
How To Get the LOV Selection Event in OAF Controller For CO Extension
 

How To Get the LOV Selection Event in OAF Controller For CO Extension

There are two ways by which you can get the LOV selection event in the OAF page.
 
1.pageContext.getLovInputSourceId()
2.pageContext.getParameter(SOURCE_PARAM)
 
 
You can write your Code in the Process Form Request of your CO Extension in this manner
 
You should know the name of your LOV Item in your OAF page so that you can compare this Name with all the Lov selection events in the OAF page because it could be possible there are more then 1 LOV's in the OAF page so you have to distinguish for which LOV selection you want to execute your custom code. 
 
if(pageContext.isLovEvent())
 
  {
String lovInputSourceId = pageContext.getLovInputSourceId();
  if("Country".equals(lovInputSourceId))
{
System.out.println("You can write your Customer Code inside this");
paramOAPageContext.writeDiagnostics(this, "LOV Selection ", 2);
 }
 } 
 

How to Compare the LOV selected value by user in the OAF Page.

 
 if(pageContext.isLovEvent()) 
 {  
      String lovInputSourceId = pageContext.getLovInputSourceId(); 

      if("Country".equals(lovInputSourceId)) {
      paramOAPageContext.writeDiagnostics(this, "LOV Selection ", 2);
           Hashtable lovResults = pageContext.getLovResultsFromSession(lovInputSourceId); 
           if(lovResults!=null) 
           { 
                String Country1 =(String)lovResults.get("Country"); // "Country" is the Return Item specified in the lovMap  

           paramOAPageContext.writeDiagnostics(this, "Selected Country "+Country1);
 
 
 
This code is used to do comparison with the LOV selected value in the OAF Page in CO Extension
 
 
How To Get the LOV Selection Event in OAF Controller For CO Extension
 



 

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

Name

Email *

Message *