What Happens When You Create a Form Using a Method That Takes Parameters What Happens at Runtime: Setting Parameters for a Method

3-14 Java EE Developers Guide for Oracle Application Development Framework Figure 3–6 Return of a Custom Method That Takes Parameters

2. In the Edit Form Fields dialog, configure the form as needed and click OK.

For help in using the dialogs, click Help. Because the method takes parameters, the Edit Action Binding dialog opens, asking you to set the value of the parameters. 3. In the Action Binding Editor, enter the value for each parameter by clicking the browse ... icon in the Value field to open the EL Expression Builder. Select the node that represents the value for the parameter. For example, the toolbar button uses a setActionListenerComponent that sets the productId parameter value on the pageFlow scope. To access that value, you would use {pageFlowScope.ProductId} as the value for the parameter. This editor uses the value to create the NamedData element that will represent the parameter when the method is executed. Since you are dropping a collection that is a return of the method unlike a method bound to a command button, this method will be run when the associated iterator is executed as the page is loaded. You want the parameter value to be set before the page is rendered. This means the NamedData element needs to get this value from wherever the sending page has set it.

3.5.2 What Happens When You Create a Form Using a Method That Takes Parameters

When you use a return of a method that takes parameters to create a form, JDeveloper: ■ Creates an action binding for the method, a method iterator binding for the result of the method, and attribute bindings for each of the attributes of the object, or in the case of a table, a table binding. It also creates NamedData elements for each parameter needed by the method. ■ Inserts code in the JSF page for the form using ADF Faces components. Example 3–9 shows the action method binding created when you drop the findProductByIdLong method, where the value for the productId was set to the ProductId attribute stored in pageFlowScope. Example 3–9 Method Action Binding for a Method Return bindings methodAction id=findProductById RequiresUpdateModel=true Action=invokeMethod MethodName=findProductById IsViewObjectMethod=false DataControl=SupplierFacadeLocal InstanceName=SupplierFacadeLocal.dataProvider ReturnName=SupplierFacadeLocal.methodResults.findProductById_ SupplierFacadeLocal_dataProvider_findProductById_result NamedData NDName=productId NDValue={pageFlowScope.ProductId} 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