Search This Blog

Accessing the ADF Binding Layer from Java

BindingContext and BindingContainer

BindingContext is a container object that holds a list of available data controls and data binding objects. It is the Java representation of all cpx files marked in your adfm.xml file. Whereas the BindingContainer class represents Java representation of the page definition file.

   import oracle.adf.model.BindingContext;
   import oracle.binding.BindingContainer;
   ...
   ...
    public BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }

The DCBindingContainer class exposes more methods than are defined by the BindingContainer interface.

import oracle.adf.model.binding.DCBindingContainer;
...
DCBindingContainer bindings = (DCBindingContainer)this.getBindings();

DCIteratorBinding
It is used to access the rowset iterator of a view object.

import oracle.adf.model.binding.DCIteratorBinding;
import oracle.jbo.Row;
...
DCBindingContainer bc = (DCBindingContainer) getBindings();
DCIteratorBinding iteratorBinding = bc.findIteratorBinding("DepartmentsIterator");
//Execute VO query by executing iterator
iteratorBinding.executeQuery();
//To gets the underlying view object for the iterator
//ViewObject vo = iteratorBinding.getViewObject();
Row currentRow = iteratorBinding.getCurrentRow();
OperationBinding

import oracle.binding.OperationBinding;
...
...
    public void updateDepartmentRow(Row currentDeptRow) {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("updateDepartments");
        operationBinding.getParamsMap().put("deptRow", currentDeptRow);
        Object returnValue = operationBinding.execute();
        if (operationBinding.getErrors().isEmpty()) {
            //No exception, Operation is success
        } else {
            //Exception is thrown from the method, handle it here
            //OperationBinding::getErrors() return list of JboException
            List errorList = operationBinding.getErrors();
            //Alternative path 'on error' go here
        }
    }

AttributeBinding

import oracle.binding.AttributeBinding;
...
...
AttributeBinding departmentName = (AttributeBinding) bindings.get("DepartmentName");


JUCtrlListBinding
To access the list binding from Java, you use the JUCtrlListBinding class, as shown next:

   import oracle.jbo.uicli.binding.JUCtrlListBinding;
   import oracle.jbo.domain.Number;
   ...
   JUCtrlListBinding listBinding = (JUCtrlListBinding) bindings.get("JobId");
   ViewRowImpl selectedListRow = (ViewRowImpl) listBinding.getSelectedValue();
   String jobIdValue = (String) selectedListRow.getAttribute("JobId");
   Number maxSalary = (Number) selectedListRow.getAttribute("MaxSalary");
 
JUCtrlHierBinding
The JUCtrlHierBinding class is used to bind tree, treetable, and table components to the ADF model.

JUCtrlHierBinding hierBinding = (JUCtrlHierBinding)bindings.get("EmployeesView3");
Access Parameter Binding

import oracle.adf.model.binding.DCBindingContainer;
...
...
    public String getPageParamater() {
        DCBindingContainer bindings = (DCBindingContainer)this.getBindings();
        Map map = bindings.getParametersMap();
        String name = map.get("name").toString();
        return null;
    }

No comments:

Post a Comment