What You May Need to Know About Setting Parameters with Methods What You May Need to Know About Using Contextual Events Instead of Parameters

Creating a Basic Databound Page 3-15 NDType=java.lang.Long methodAction ... bindings Note that the NamedData element will evaluate to productID on the pageFlowScope , as set by any requesting page.

3.5.3 What Happens at Runtime: Setting Parameters for a Method

Unlike a method executed when a user clicks a command button, a method used to create a form is executed as the page is loaded. When the method is executed in order to return the data for the page, the method evaluates the EL expression for the NamedData element and uses that value as its parameter. It is then able to return the correct data. If the method takes more than one parameter, each is evaluated in turn to set the parameters for the method. For example, when the ProductInfo page loads, it takes the value of the ProductId parameter on the pageFlow scope, and sets it as the value of the parameter needed by the findProductByIdInteger method. Once that method executes, it returns only the record that matches the value of the parameter. Because you dropped the return of the method to create the form, that return is the product that is displayed.

3.5.4 What You May Need to Know About Setting Parameters with Methods

There may be cases where an action on one page needs to set parameters that will be used to determine application functionality. For example, you can create a command button on one page that will navigate to another page, but a component on the resulting page will display only if the parameter value is false. You can use a managed bean to pass this parameter between the pages, and to contain the method that is used to check the value of this parameter. A setPropertyListener component with the type property set to action, which is nested in the command button, is then used to set parameter. For more information about setting parameters using methods, see the Setting Parameter Values Using a Command Component section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework.

3.5.5 What You May Need to Know About Using Contextual Events Instead of Parameters

Often a page or a region within a page needs information from somewhere else on the page or from a different region for more information about regions, see the Using Task Flows as Regions sections of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. While you can pass parameters to obtain that information, doing so makes sense only when the parameters are well known and the inputs are EL-accessible to the page. Parameters are also useful when a task flow may need to be restarted if the parameter value changes. Note: If you are using task flows, you can use the task flow parameter passing mechanism. For more information, see the Using Parameters in Task Flows chapter of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. 3-16 Java EE Developers Guide for Oracle Application Development Framework However, suppose you have a task flow with multiple page fragments that contain various interesting values that could be used as input on one of the pages in the flow. If you were to use parameters to pass the value, the task flow would need to surface output parameters for the union of each of the interesting values on each and every fragment. Instead, for each fragment that contains the needed information, you can define a contextual event that will be raised when the page is submitted. The page or fragment that requires the information can then subscribe to the various events and receive the information through the event. You can create and configure contextual events using a page definition file. For more information, see the Creating Contextual Events section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework.

3.6 Creating a Form to Edit an Existing Record

You can create a form that allows a user to edit the current data, and then commit those changes to the data source. To do this, you use methods that can modify data records associated with the collection to create command buttons. For example, you can use the default mergeSuppliersSuppliers method to create a button that allows a user to update a supplier. If the page is not part of a bounded task flow, you need to use the merge or persist method associated with the collection to merge the changes back into the collection for more information about the difference between the two, see Section 3.6.3, What You May Need to Know About the Difference Between the Merge and Persist Methods . If the page is part of a transaction within a bounded task flow, you use the commit and rollback operations to resolve the transaction in a 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.6.1 How to Create Edit Forms

To use methods on a form, you follow the same procedures as with the operations. To create an edit form: 1. From the Data Controls panel, drag the collection for which you wish to create the form, and choose ADF Form from the context menu. This creates a form using inputText components, which will allow the user to edit the data in the fields. 2. From the Data Controls panel, select the merge or persist method associated with the collection of objects on which you wish the operation to execute, and drag it onto the JSF page. For example, if you want to be able to update a supplier record and will not be working with that instance again, you would drag the mergeSuppliersSuppliers method. For more information about the difference between the merge and persist methods, see Section 3.6.3, What You May Need to Know About the Difference Between the Merge and Persist Methods.

3. From the ensuing context menu, choose either ADF Button or ADF Link.

4. In the Edit Action Binding dialog, you need to populate the value for the method’s parameter. For the merge methods and the other default methods, this is the object being updated.