Tuesday, June 27, 2017

Playing around with ADF dataControl

While trying to figure out what one of our ex-colleagues at REALSOFT is programming a business rule engine admin screen for the Health Insurance Administration card issuance and administration software solution, i noticed the following piece of code

    AppModuleImpl appmodule =
        (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");

this piece of code is specific for the Oracle Application Development Framework that we use to build JEE web scalable , mission critical applications.

Being a principal in the company, i try to find ways not only to optimize the coding endeavor , but also to minimize costs. 

One way of doing that is obviously  by building reusable libraries, encapsulate the nitty-gritty issues and minimizing the things that the developer needs to understand about the framework in order to getting his applications up and running.

What i do not like about the above is that fact that the developer needs to know the Data Control  Name in order to access the ApplicationModule object 

 What i have in mind is to create a method that will get does not need the developer to know more that the method name in order to get the application module.  I fiddled around with helper classes found the following


public class Ammar {
    public Ammar() {
        super();
    }
    public void PlayWithDataControl(){
        DCBindingContainer binding =   (DCBindingContainer)ADFUtils.getBindingContainer();
        DCDataControl cDataControl = binding.getDataControl();
        ApplicationModule AM =cDataControl.getApplicationModule();
//        System.out.println(cDataControl.getName());  to make sure i am within the same data control
// another legitimate question is what if i have more that one page in the application, am i getting the application module pertaining to the page definition i am on?  well , the test below indicates that the answer is yes,, i created two pages, and called the following code from both, and each printed its own page definition name

System.out.println(    binding.getDef().getContainerName());
      
    }

So ,  i would just modify the above and add it to company Library

    public ApplicationModule getRSMyAppMod(){
        DCBindingContainer binding =  (DCBindingContainer)ADFUtils.getBindingContainer();
        return binding.getDataControl().getApplicationModule();
    }

you can then call it from your view controller ,, something like this, i am using strongly typed implementation here

    public String cb6_action() {
        // Add event code here...
        AppModuleImpl appMod = (AppModuleImpl)getRSMyAppMod();
        ViewObject vo = appMod.getEmpView1();
        ViewObjectImpl empView1 = appMod.getEmpView1();
}

Another corollary of the Binding container which i liked is the fact that i can fetch all the binding attributes

        List attrBindings = binding.getAttributeBindings();
        Iterator itr = attrBindings.iterator();
        while (itr.hasNext()){
            AttributeBinding attrBinding = (AttributeBinding)itr.next();
            String val = attrBinding.getInputValue().toString();
            System.out.println(val);

Yes another corollary is that one can find the  value of an attribute from the binding container directly by using the method    attrBinding.getName();


also i found in the ADFUtils helper method the following which return the value of any bound attribute..  This is very nice, and will make the life of people coming from forms background easier.
Just call the method ScreenValue instead of the getBoundAttribute, and it will be all fun


    public static Object getBoundAttributeValue(String attributeName) {
        return findControlBinding(attributeName).getInputValue();

Ammar  Sajdi  Third day of Eid at office enjoying the heat wave 35C

No comments:

Getting Ref of the View Object referenced by the current Iterator binding for One iterator page without knowing the name of the iterator

Getting Ref of the View Object referenced by the current Iterator binding for One iterator page without knowing the name of the iterator ...