Saturday, 11 June 2016

ADF Equivalents of Common Oracle Forms Triggers : Pre-Query (Query Processing)

Hello all  ,
today i have in my office have an use case , in which i have apply the "Oracle Forms Triggers in adf "
, i have done it by simply some tricky way ,

so then i decide to write blogs about the
"Equivalents Of Common Oracle forms Triggers", 
in which i will describe how can we achieve the oracle forms like behavior in ADF,

Today's Discussion:
                                  For this time i have select the Pre-query trigger from the category of Query Processing.

first of all let us know the functionality of Pre-Query trigger ,

Pre-Query Trigger:
                                      as we know the trigger is   
"a special kind of stored procedure that automatically executes when an event occurs in the database server"
so a Pre-Query trigger is :
Execute logic before executing a query in a data block.
know let us look how can we do it in ADF.

i will use the HR schema , and for the sake of simplicity just show the some sop in log window to ensure the result 

Solution :

here are simple steps you have to follow to achieve this , 

step1:
           first of all create simple application and create the entities and viewobjects of Departments And employees tables , 

step2
          Now double click on one of your view object say
DepartmentsView --> overview ---->Java --> click on pencil button on right top as in figure


Step3:
this will open a window in front of you , check the GenerateViewObject class and under this check the "Include Custome Java data Source Methodes"
as in figure



This will create the custome ViewImpl class for Departments View Name as "DepartmentsViewImpl.java".

Step4 :

now open DepartmentsViewImpl.java, and find the methode  

executeQueryForCollection()

override it as below ,
i am just adding the sop before calling the super , this will perform same functionality as Pre-Query performs in Oracle forms

 protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {
        //
       System.out.println("Performing Pre-Query in ADF");
        super.executeQueryForCollection(qc, params, noUserParams);
    }

save all and run the Application module. ,and double click on DepartmentsView , see your j dev log window , you will see the lines are written in log. as


thats it :)


Coclusion:

Performing Forms like Behavior in ADF is bit different approach , as we have to do our stuff with Cistom classes ,perhaps it is a basic technique i have shown here , 
you can use complex logic whcih you want to perform before querying from departments table , 

you can cretae a methode in DepartmentsViewImpl.java and then call it  in executeQueryForCollection() just before calling super as , 

for example if we have a methode name as showLines() in DepartmentsViewImpl.java

public void showLines() 


               //Perform Some Logics
     System.out.println("Performing Pre-Query in ADF");
}

and call it in executeQueryForCollection() just before calling super.
as

 protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {
       
        this.showLines();  //calling showLines function
        super.executeQueryForCollection(qc, params, noUserParams);
    }



hope it is help ful for you :)

Learn and share , 

Regards
Zeeshan Ali 


No comments:

Post a Comment