Oracle® Application Development Framework Developer's Guide
10g Release 3 (10.1.3) B25386-01 |
|
![]() Previous |
![]() Next |
You can add ADF bindings to buttons or links. When you add a binding to a button or link, you use a method or operation from the data control. When a user clicks the button or link, the method or operation is invoked.
If you want the button or link to perform page navigation, after adding the ADF binding you must bind the action
attribute of the component tag to a backing bean, which will handle the navigation. The backing bean must inject the ADF binding container and return an outcome value. For information about creating navigation rules and binding navigation components to backing beans, see Chapter 9, "Adding Page Navigation Using Outcomes".
To add ADF bindings to a button or link, you drag a method or operation from the Data Control Palette and drop it on the button or link tag displayed in the Structure window. For general tips about dropping items from the Data Control Palette onto the Structure window, see Section 13.1.1, "How to Add ADF Bindings to Components Using the Data Control Palette".
To add ADF bindings to a button or link:
With the page displayed in the Design page of the visual editor, open the Structure window.
In the Design page of the visual editor, select the button or link. The tag selected in the Structure window must be one of the tags listed previously in Table 13-1. JDeveloper simultaneously selects the corresponding tag in the Structure window. If the incorrect tag is selected, make the adjustment in the Structure window.
From the Data Control Palette, drag a method or operation to the Structure window and drop it on the selected button or link tag.
On the Data Control Palette context menu, choose Bind Existing CommandButton or Bind Existing CommandLink.
If the method requires a parameter, the Action Binding Editor appears where you define the parameter values to pass to the method. (For more information about passing parameters to methods, see Chapter 10, "Creating More Complex Pages".)
Example 13-7 displays a command button before the ADF bindings are added.
Example 13-8 displays the same button after the findAllStaff()
method from the SRDemo data control was dropped on it. The findAllStaff
method returns the User
collection. The binding replaced the original button label with the name of the method; you can change the button label using the Property Inspector. An actionListener
attribute was added with a binding on the findAllStaff
method. The actionListener
detects when the user clicks the button and executes the method as a result. If you want the button to navigate to another page, you can bind to a backing bean or add an action
value. For more information, see Chapter 9, "Adding Page Navigation Using Outcomes".
Example 13-8 ADF Faces Command Button After ADF Bindings Are Added
<af:commandButton text="findAllStaff" actionListener="#{bindings.findAllStaff.execute}" disabled="#{!bindings.findAllStaff.enabled}"/>
In addition to adding the bindings to the button, JDeveloper automatically adds a methodAction
binding object to the page definition file, as shown in Example 13-9.
Example 13-9 Binding Object Added to the Page Definition File for a Command Button
<bindings> <methodAction id="findAllStaff" InstanceName="SRPublicFacade.dataProvider" DataControl="SRPublicFacade" MethodName="findAllStaff" RequiresUpdateModel="true" Action="999" ReturnName="SRPublicFacade.methodResults.SRPublicFacade_ dataProvider_findAllStaff_result"/> </bindings>
For more information about databound buttons and links, see Chapter 6, "Creating a Basic Page".