Skip Headers
Oracle® Application Development Framework Developer's Guide
10g Release 3 (10.1.3)
B25386-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

13.3 Adding ADF Bindings to Text Fields in a Form

You bind forms or other container components by binding the individual text fields that comprise the component: you cannot bind an entire form at one time. You bind a text field to an attribute in a collection.

13.3.1 How to Add ADF Bindings to Text Fields in a Form

To add ADF bindings to a text field, you drag an attribute from the Data Control Palette and drop it on the text field component 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 text field:

  1. With the page displayed in the Design page of the visual editor, open the Structure window.

  2. In Design page of the visual editor, select the text field. This simultaneously selects the tag in the Structure window. The text field tag must be one of the tags listed previously in Table 13-1. If the incorrect tag is selected, make the adjustment in the Structure window.

  3. From the Data Control Palette, drag an attribute to the Structure window and drop it on the selected text field.

  4. On the Data Control Palette context menu, choose Bind Existing Input Text.

    The binding is added to the text field.

13.3.2 What Happens When You Add ADF Bindings to a Text Field

Example 13-1 displays an input text field component before the ADF bindings are added. Notice that the component is a simple tag with a static label value of First Name.

Example 13-1 Text Field Component Before ADF Bindings

<af:inputText label="First Name"/>

Example 13-2 displays the same text field after the firstName attribute of the User data collection from the SRDemo data control was dropped on it. The User collection is returned by the findAllStaff method. Notice that the label was replaced with a binding expression. To modify the label displayed by an ADF binding, you can use control hints. Other tag attributes have been added with bindings on different properties on the FirstName attribute. For a description of each binding property, see Appendix B, "Reference ADF Binding Properties".

Example 13-2 Text Field Component After ADF Bindings Are Added

<af:inputText label="#{bindings.FirstName.label}"
              value="#{bindings.FirstName.inputValue}"
              required="#{bindings.FirstName.mandatory}"
              columns="#{bindings.FirstName.displayWidth}">
   <af:validator binding="#{bindings.FirstName.validator}"/> 
</af:inputText>

In addition to adding the bindings to the text field, JDeveloper automatically adds entries for the databound text field to the page definition file, as shown in Example 13-3. The page definition entries include an iterator binding object defined in the executables element. The iterator binding object iterates over the business objects of the User collection and exposes the row currency and range state to the bindings. Also, the bindings element contains a value binding for the text field.

For more information about databound text fields and forms, see Chapter 6, "Creating a Basic Page".

Example 13-3 Binding Objects Added to the Page Definition File for a Text Field

<executables>
    <iterator id="UserView1Iterator" RangeSize="10" Binds="UserView1"
              DataControl="AppModuleDataControl"/>
</executables>
<bindings>
    <attributeValues id="FirstName" IterBinding="UserView1Iterator">
      <AttrNames>
        <Item Value="FirstName"/>
      </AttrNames>
    </attributeValues>
</bindings>