What Happens When You Use Methods to Change Data

Creating a Basic Databound Page 3-17

a. In the Parameters section, use the Value dropdown list to select Show EL

Expression Builder . b. In the Expression Builder, expand the node for the accessor’s iterator, then expand the currentRow node, and select dataProvider. This will create an EL expression that evaluates to the data for the current row in the accessor’s iterator.

c. Click OK.

For example, if you created a form using the suppliersFindAll accessor collection, then JDeveloper would have created an accessorIterator binding named suppliersFindAllIterator. You would need to select the dataProvider for the current row under that iterator, as shown in Figure 3–7 . This reference means that the parameter value will resolve to the value of the row currently being shown in the form. Figure 3–7 dataProvider for the Current Row on the suppliersFindAllIterator Binding

3.6.2 What Happens When You Use Methods to Change Data

When you drop a method as a command button, JDeveloper: ■ Defines a method binding for the method. If the method takes any parameters, JDeveloper creates NamedData elements that hold the parameter values. For more Note: If the page is part of a transaction within a bounded task flow, then instead of creating a button from the merge method or other default method, you would set that method as the value for the transaction resolution when creating the task flow return activity. For more information, see the Using Task Flow Return Activities section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. 3-18 Java EE Developers Guide for Oracle Application Development Framework information about NamedData elements, see Section 3.5.3, What Happens at Runtime: Setting Parameters for a Method. ■ Inserts code in the JSF page for the ADF Faces command component. This code is the same as code for any other command button, as described in Section 3.6.2.2, Using EL Expressions to Bind to Methods. However, instead of being bound to the execute method of an action binding for an operation, the buttons are bound to the execute method of the action binding for the method that was dropped.

3.6.2.1 Method Bindings

Similar to when you create a button from a built-in operation, when you create a button from a method, JDeveloper creates an action binding for the method. Example 3–10 shows the action binding created when you drop the mergeSuppliersSuppliers method. Example 3–10 Page Definition Code for an Action Binding Used by the Iterator bindings methodAction id=mergeSuppliers RequiresUpdateModel=true Action=invokeMethod MethodName=mergeSuppliers IsViewObjectMethod=false DataControl=SessionEJBLocal InstanceName=SessionEJBLocal.dataProvider ReturnName=SessionEJBLocal.methodResults.mergeSuppliers_ SessionEJBLocal_dataProvider_persistSuppliers_result NamedData NDName=suppliers NDType=model.Suppliers methodAction bindings In this example, when the binding is accessed, the method is invoked because the action property value is invokeMethod. When you drop a method that takes parameters onto a JSF page, JDeveloper also creates NamedData elements for each parameter. These elements represent the parameters of the method. For example, the mergeSuppliersSuppliers method action binding contains a NamedData element for the Suppliers parameter.

3.6.2.2 Using EL Expressions to Bind to Methods

Like creating command buttons using navigation operations, when you create a command button using a method, JDeveloper binds the button to the method using the actionListener attribute. The button is bound to the execute property of the action binding for the given method. This binding causes the binding’s method to be invoked on the business service. For more information about the actionListener attribute, see the What Happens at Runtime: How Action Events and Action Listeners Work section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. Like navigation operations, the disabled property on the button uses an EL expression to determine whether or not to display the button. Example 3–11 shows the Tip: Instead of binding a button to the execute method on the action binding, you can bind the button to a method in a backing bean that overrides the execute method. Doing so allows you to add logic before or after the original method runs. For more information, see Section 3.6.4, What You May Need to Know About Overriding Declarative methods. Creating a Basic Databound Page 3-19 EL expression used to bind the command button to the mergeSuppliersSuppliers method. Example 3–11 JSF Code to Bind a Command Button to a Method af:commandButton actionListener={bindings.mergeSupplier.execute} text=mergeSupplier disabled={bindings.mergeSupplier.enabled} id=cb1

3.6.3 What You May Need to Know About the Difference Between the Merge and Persist Methods