In the overview editor for any page definition’s Bindings and Executables tab, click the Add icon in the Bindings section. From the Insert Item dialog, you're allowed to choose either action or methodAction binding object to create as shown below:
The description for the action item is "Binding for Action." So, it is named action binding. The description for the methodAction item is "Method binding for the Control." It is also known as method binding. In this article, we'll examine what're the differences and similarities of these two binding objects.
Acronyms
- ADFm: ADF Model layer
- ADFc: ADF Controller
- ADFv: ADF View layer
- EL: Expression Language
Action Binding
Action binding object can be used to bind command components, such as buttons or links, to built-in data control operations (such as Commit or Rollback) or to built-in collection-level operations (such as Create, Delete, Next, Previous, or ExecuteWithParams).Action binding is defined in the page definition using the following attributes:
Attributes | Attribute Description |
Action | Fully qualified package name. Identifies the class for which the data control is created. In the case of the EJB session facade, this is the session bean. |
BindingClass | This is for backward compatibility to indicate which class implements the runtime for this binding definition. This is used by earlier versions of JDeveloper. |
DataControl | Name of the DataControl usage in the bindingContext (.cpx) which this iteratorBinding or actionBinding is associated with. |
Execute | Used by default when you drop an operation from the Data Controls Panel in the automatically configured ActionListener property. It results in executing the action binding's operation at runtime. |
InstanceName | Specifies the instance name for the action. |
IterBinding | Specifies the iteratorBinding instance in this bindingContainer to which this binding is associated. |
Outcome | Use if you want to use the result of a method action binding (once converted to a String) as a JSF navigation outcome name. |
For example, ExecuteWithParams (i.e., a built-in collection-level operation) is defined in a page definition file as:
<bindings> <action IterBinding="TestTrendIterator" id="ExecuteWithParams" RequiresUpdateModel="true" Action="executeWithParams"> <NamedData NDName="TSBegin" NDType="java.sql.Date" NDValue="${bindings.ExecuteWithParams_TSBegin}"/> <NamedData NDName="TSEnd" NDType="java.sql.Date" NDValue="${bindings.ExecuteWithParams_TSEnd}"/> </action> </bindings>
Note that ExecuteWithParams on our view object (not shown here) takes two parameters:
- TSBegin
- TSEnd
Method Binding
Method bindings are similar to action bindings. But, they are used to bind to methods defined in an ADF BC application, view object, or view row client interfaces.Method binding is defined in the page definition using the following attributes:
Attributes | Attribute Description |
Action | Fully qualified package name. Identifies the class for which the data control is created. In the case of the EJB session facade, this is the session bean. |
BindingClass | This is for backward compatibility to indicate which class implements the runtime for this binding definition. This is used by earlier versions of JDeveloper. |
ClassName | This is the class to which the method being invoked belongs. |
DataControl | Name of the DataControl usage in the bindingContext (.cpx) which this methodAction is associated with. |
DefClass | Used internally by ADF. |
id | Unique identifier. May be referenced by any ADF action binding. |
InstanceName | A dot-separated EL path to a Java object instance on which the associated method is to be invoked. |
IsLocalObjectReference | Set to true if the instanceName contains an EL path relative to this bindingContainer. |
IsViewObjectMethod | Set to true if the instanceName contains an instance path relative to the associated data control's application module. |
MethodName | Indicates the name of the operation on the given instance or class that needs to be invoked for this methodActionBinding. |
RequiresUpdateModel | Whether this action requires that the model be updated before the action is to be invoked. |
ReturnName | The EL path of the result returned by the associated method. |
For example, myCustomMethod defined in an ADF BC application is defined to be:
<bindings> <methodAction id="myCustomMethod" InstanceName="SelTestPortalAMDataControl.dataProvider" DataControl="SelTestPortalAMDataControl" RequiresUpdateModel="true" Action="invokeMethod" MethodName="refreshTotalComments" IsViewObjectMethod="false"/> </bindings>
How to Access Action/Method Bindings in an Fusion Web Application
When working with Fusion web applications using the ADF Model layer for data binding, JDeveloper configures a servlet filter in your user interface project called the ADFBindingFilter. It orchestrates the automatic acquisition and release of an appropriate application module instance based on declarative binding metadata, and ensures that the service is available to be looked up as a data control using a known action binding or iterator binding, specified by any page definition file in the user interface project.No matter what a binding object is (i.e., action binding or method binding), they are retrieved and invoked in the same way when accessed from Fusion Web Applications:
- Retrieve them from the DCBindingContainer (i.e., the runtime object that embodies the meta data defined in the page definition) by naming an action binding or method binding.
BindingContext context = BindingContext.getCurrent(); DCBindingContainer bindingContainer = (DCBindingContainer) context.getCurrentBindingsEntry(); OperationBinding oper = bindingContainer.getOperationBinding("openSubTask"); ... oper.execute();
FacesCtrlAttrsBinding
Internally JUCtrlActionBinding is an FacesCtrlActionBinding, which is the class that connects ADFv[1] command components to ADFc[2]/ADFm[3]. Like other ADFv binding classes, this is a sub-class of an ADFm class. And like other ADFm bindings there is an entry in the pageDef.xml file for this binding (i.e., action or method binding). If the method has either parameters or a return, there will be additional attribute bindings corresponding to the parameter and return values. These attribute bindings will correspond to a FacesCtrlAttrsBinding class and be in the pageDef.xml file.
The ADFv command components that use this class are:
- commandLink
- commandButton,
- commandMenuItem
- commandToobarButton
- commandImageLink.
Learn More