Wednesday, April 29, 2015

Invoke ADF Data Control Operation via Bindings Layer

Assumptions:

  • You have created a data control.
  • You have created a methodAction binding for the respective operation on a page.
package com.bjwallen.examples;

import oracle.binding.AttributeBinding; 
import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;
import oracle.adf.model.BindingContext;

public class BindingsExample{

  public BindingsExample(){
    super();
  }

  public void invokeOperation() {
    // get a handle on the bindingContainerBindingContainer
    bindingContainer = BindingContext.getCurrent().getCurrentBindingsEntry();
    
    // get a handle on the operation you want to invoke
    OperationBinding operationBinding = bindingContainer.getOperationBinding("yourOperation");
    
    // get a handle on an attribute that is bound to some component on a page
    AttributeBinding yourAttr = (AttributeBinding)bindingContainer.getControlBinding("yourComponentBinding");
    
    // put the value of the attribute in an operationBinding map
    operationBinding.getParamsMap().put("yourKey", yourAttr.getInputValue().toString();
    
    // invoke your operation
    operationBinding.execute();
    
    // check for any exceptions
    if (!operationBinding.getErrors().isEmpty()) {
      // handle exceptions accordingly
    }
  }
}


If you're dealing with complex types in the WSDL, you can update the request using the DCBindingIterator.

// cast your bindingContainer to a DCBindingContainer
DCBindingContainer dcBindingContainer = (DCBindingContainer)bindingContainer;

// get the data control iterator
DCIteratorBinding dcIteratorBinding = dcBindingContainer.findIteratorBinding("yourIterator");

// update the row with the value of an attribute bound to a page
Row row = dcIteratorBinding.getCurrentRow();
String value = yourAttr.getInputValue().toString();
row.setAttribute("DateTime", value);



References:
http://biemond.blogspot.com/2009/03/some-handy-code-for-backing-beans-adf.html
http://steve-hawes.blogspot.com/2011/11/invoking-web-service-from-adf-managed.html

No comments:

Post a Comment