Friday 6 May 2016

Access ADF Bindings from Managed Bean

Access ADF Bindings from Managed Bean

ADF enables bindings through Oracle ADF Model layer. whenever ADF view layer is created JDeveloper creates data bound client and thus enable the bridge between model and view components to access data .In some cases we may want to access page bindings Programatically from managed bean . Lets see how it can be done.

Look at the screen shot of the page bindings section of a jsff page.


When u drag and drop employee data control on to the page, Bindings section will contain the data control instance and executable section contains Employee Iterator .

Now lets see how we can access table bindings from Managed Bean . The Code to access.

        DCBindingContainer bindings2 = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
              
        JUCtrlHierBinding obj = (JUCtrlHierBinding)bindings2.findCtrlBinding("EmployeesEOView1");
        ViewObject vo= obj.getViewObject();
        
        //some operations on it
       
        vo.setNamedWhereClauseParam("BindEmployeeId",101);
        vo.executeQuery();


The same way we can get Iterator bindings too ..

     DCBindingContainer bindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
              
        DCIteratorBinding roleIter = bindings.findIteratorBinding("EmployeesEOView1Iterator");

        ViewObject obj = roleIter.getViewObject();

Execution of Operation binding

BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
        OperationBinding operationBinding = bindings.getOperationBinding("CreateInsert");
        Object result = operationBinding.execute();
       
        //Custom Method
        BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();
        OperationBinding method = bindings1.getOperationBinding("methodBindingId");
        Map args = method .getParamsMap();
        args.put(“argument1”, argument1Value);
        method .execute();
        

 

1 comment: