The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

Determine the arguments of an operation binding at runtime

Frank Nimphius
Master Principal Product Manager

On the OTN forum, Navaneetha Krishnan answered a question
of how to access an Operation Binding at runtime and determine the arguments it
expects. Background of the question is that if you call getParamsMap() on the Operation
Binding, it does not contain the keys of the method arguments.

The example code shown below accesses an OperationBinding that
is defined in the PageDef file for a method. It then dynamically parses the
binding definition for configured method argument names.

For example, a method to relocate employees may be exposed
on the ADF Business Component model and exposed in the Data Control panel for
drag and drop UI binding in ADF. The method signature of the sample may be as
shown below

departmentId, Number employeeId,
Boolean withSalaryRaise,
Long salaryRaiseInPercent)

The easiest way for you to create a method like the one
below, is to drag and drop the method from the DataControls panel to the page
and have it rendered as a button or link. A binding dialog opens for you to
define default values or reference objects that provide the argument values at

Double click the command item to create a managed bean method
that contains generated code for the operation to invoke ("relocateEmployee"
in the sample). The following managed bean method was built this way and then
extended with the code posted by Navaneetha.

The code sample has a place holder line for where your application
would look up the argument values to pass to the method. For example, if there
is a HashMap available (e.g. exposed by a managed bean, or passed as an input
parameter to a bounded task flow) then you could check if it contains values
for the operation argument names you read from the OperationBinding.

import oracle.adf.model.BindingContext;
import oracle.adf.model.OperationParameter;
import oracle.adf.model.binding.DCInvokeMethod;
import oracle.adf.model.binding.DCInvokeMethodDef;
import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;

//method called from a
command item in ADF Faces
public String onRelocateEmployee() {
   //generated binding access code
   BindingContainer bindings = getBindings();
   //access the method binding in the  PageDef file
   OperationBinding operationBinding =
   //to pass arguments to an operation binding, a Map is used.
   //the Map is retrieved by a call to getParamsMap on the operation
   Map operationParamsMap = operationBinding.getParamsMap();
   //get access to the operation definition
   DCInvokeMethod method =
   if (method != null)
     DCInvokeMethodDef methodDef = method.getDef();
     if(methodDef != null)
          OperationParameter[] operationParameters = null;
         operationParameters = methodDef.getParameters();
       if (operationParameters != null) {
           for (OperationParameter operationParameter : operationParameters)
              String argumentName = operationParameter.getName();
              Object argumentType = operationParameter.getTypeName();
              Object defaultValue = operationParameter.getValue();
              if (argumentName != null) {
                Object value = <determine value for argumentNname>;
                operationParamsMap.put(argumentName, value != null ?
                                        value : defaultValue);
    //the operation arguments are provided. Now it is time to
  //execute it
  Object result = operationBinding.execute();
  if (!operationBinding.getErrors().isEmpty())
     //TODO log error
    //TODO handle error
    return null;
  return null;

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.