Skip Headers
Oracle® Fusion Middleware Mobile Client Developer's Guide for Oracle Application Development Framework
11g Release 1 (11.1.1.5.0)

Part Number E14826-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

D Sample Code

This document shows examples of the OperationProvider and OperationDelegate which provide an older means of simulating dynamic method bindings. These interfaces have been superseded and are included in this document for backward compatibility. Currently, the ADF Mobile runtime uses MethodDispatch, as described Chapter 7, "Extending ADF Mobile Client Applications with Java" instead.

This document includes the following sections:

D.1 Using the OperationProvider and OperationDelegate Interfaces

Example D-2 illustrates a sample implementation of an OperationProvider and OperationDelegater to call custom methods. Example D-1 illustrates the corresponding metadata in the page definition file.

Example D-1 The bindings Metadata

</bindings>
       ...
      <methodAction id="Foo" InstanceName="AppModuleDataControl.dataProvider"
                                 DataControl="AppModuleDataControl" RequiresUpdateModel="true"
                                 Action="invokeMethod" MethodName="Foo"
                                 IsViewObjectMethod="false">
         <NamedData NDName="text" NDValue="testString" NDType="java.lang.String"/>
      </methodAction>
</bindings>

Example D-2 Using OperationProvider and OperationDelegate

package oracle.apps.sales.mobile.view;
 
import oracle.adfnmc.bindings.DataControl;
import oracle.adfnmc.bindings.OperationDelegate;
import oracle.adfnmc.bindings.dbf.OperationProvider;
import oracle.adfnmc.java.util.List;
 
import oracle.apps.sales.mobile.model.entities.LeadEOImpl;
import oracle.apps.sales.mobile.uiModel.views.LeadVOImpl;
 
import oracle.jbo.server.ApplicationModuleImpl;
 
public class CustomOperationProvider implements OperationProvider
{
  public CustomOperationProvider()
  {
  }
 
  public OperationDelegate getCustomOperation(Object module, String instanceName, String methodName)
  {
    if (instanceName.equals("AppModuleDataControl.dataProvider"))
    {
      if (methodName.equals("testMethod"))
      {
        return new testMethodDelegate();
      }
      else
      {
        // etc...
      }         
    }
    else if (instanceName.equals("AppModuleDataControl.LeadVO1"))
    {
      if (methodName.equals("convertLeadToOpty"))
      {
        return new convertLeadToOptyDelegate();
      }
      else
      {
        // etc...
      }
    }
    else if (instanceName.equals("AppModuleDataControl.OptyVO1"))
    { 
      // etc...
    }
    
    return null;
  }
 
  private static final class convertLeadToOptyDelegate implements OperationDelegate
  {
    public Object execute(Object instance, List params)
    {
      ((LeadVOImpl)instance).convertLeadToOpty();
      return null;
    }
  }
 
  private static final class testMethodDelegate implements OperationDelegate
  {
    public Object execute(Object instance, List params)
    {
      String arg0 = (String)params.get(0);
      return ((ApplicationModuleImpl)instance).testMethod(arg0);
    }
  }
}