Skip Headers
Oracle® Application Development Framework Developer's Guide
10g (10.1.3.1.0)

Part Number B28967-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

13.5 Adding ADF Bindings to Tables

You can add ADF bindings to an entire table at one time. In fact, it is recommended to bind the entire table instead of the individual components that comprise the table. When you add a binding to a table, you can drag an entire collection from the Data Control Palette onto the table. You can bind an individual column, but only if the table is already bound to an iterator.

13.5.1 How to Add ADF Bindings to Tables

To add ADF bindings to a table, you drag a data collection from the Data Control Palette and drop it on the table tag displayed in the Structure window. For general tips about dropping items from the Data Control Palette onto the Structure window, see Section 13.3.1, "How to Add ADF Bindings Using the Data Control Palette".

To add ADF bindings to a table:

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

  2. In the Design page of the visual editor, select the table.

    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. For example, if a column tag is selected, select the table tag instead.

  3. From the Data Control Palette, drag a collection to the Structure window and drop it on the selected table tag.

  4. On the Data Control Palette context menu, choose Bind Existing ADF Table or Bind Existing ADF Read-only Table. The Edit Table Column dialog appears, as shown in Figure 13-4.

    Figure 13-4 Edit Table Column Dialog

    Edit Table Column dialog

    The Display Label column in the dialog displays the placeholder column headings entered when the table was created. In the example, the placeholder column headings are First Name, Last Name, Email, and User ID. The Value Binding column displays the attributes from the data collection. The Component to Use column displays the types of components each table column will contain.

  5. In the Edit Table Columns dialog, use the dropdowns in the Value Binding fields to choose the attributes from the data collection to be bound to each column in the table, as shown in Figure 13-5. If placeholder column headings were entered when the table was created, match the attributes to the appropriate column headings. For example, if a column heading is First Name, you would choose the firstName attribute from the Value Binding dropdown next to that column heading.

    Figure 13-5 Value Binding Dropdown in the Edit Table Columns Dialog

    Value Binding Dropdown in the Edit Table Columns dialog.

    Tip:

    If you need to add additional columns to the table, click New.

    For more information about tables, see Chapter 7, "Adding Tables".

13.5.2 What Happens When You Add ADF Bindings to a Table

Example 13-3 displays a table before the ADF bindings are added. The table defines four columns and uses static placeholder values as column headings: First Name, Last Name, Email, and User ID. The table also defines a range navigation of 15 rows, table banding, and a selection facet.

Example 13-3 ADF Faces Table Before ADF Bindings

<af:table emptyText="No items were found" rows="15" banding="none"
          bandingInterval="1">
     <f:facet name="selection">
       <af:tableSelectOne/>
     </f:facet>
     <af:column sortable="false" headerText="First Name">
       <af:outputText value="#{row.col1}"/>
     </af:column>
     <af:column sortable="false" headerText="Last Name">
       <af:outputText value="#{row.col2}"/>
     </af:column>
</af:table>

Example 13-4 displays the same table after the User data collection returned by the findAllStaff method from the SRDemo data control was dropped on it. Notice that since the placeholder column headings were static values, they have been replaced with a binding on the findAllStaff1 iterator. However, the selection facet and banding from the original table remain intact. The selectionState and selectionListener attributes have been added with bindings on the binding object.

The range navigation value is replaced by a binding on the iterator, which manages the current row. The rangeSize binding property, which defines the number of rows can be set in the page definition file. For a description of each binding property, see Appendix B, "Reference ADF Binding Properties".

Example 13-4 ADF Faces Table After ADF Bindings Are Added

<af:table emptyText="#{bindings.findAllStaff1.viewable ? 'No rows yet.' : 'Access
                        Denied.'}"
          rows="#{bindings.findAllStaff1.rangeSize}" banding="none"
          bandingInterval="1"
          value="#{bindings.findAllStaff1.collectionModel}" var="row"
          first="#{bindings.findAllStaff1.rangeStart}"
          selectionState="#{bindings.findAllStaff1.collectionModel.
                            selectedRow}"
          selectionListener="#{bindings.findAllStaff1.collectionModel.
                                makeCurrent}">
     <f:facet name="selection">
       <af:tableSelectOne/>
     </f:facet>
     <af:column sortable="false"
                headerText="#{bindings.findAllStaff1.labels.firstName}"
                sortProperty="firstName">
        <af:outputText value="#{row.firstName}"/>
     </af:column>
     <af:column sortable="false"
                headerText="#{bindings.findAllStaff1.labels.lastName}"
                sortProperty="lastName">
        <af:outputText value="#{row.lastName}"/>
     </af:column>
</af:table>

In addition to adding the bindings to the table, JDeveloper automatically adds entries for the databound table to the page definition file. The page definition entries include an iterator binding object defined in the executables element and the value bindings for the table in the bindings element. By default, the RangeSize property on the iterator binding is set to 10. This value is now bound to the range navigation in the table and overrides the original range navigation value set in the table before the bindings were added. In the example, the original table set the range navigation value at 15. If necessary, you can change the RangeSize value in the page definition to match the original value defined in the table.

The bindings element contains a methodAction, which encapsulates information about how to invoke the method iterator, and value bindings for the attributes available to the table. The value bindings include all the attributes of the returned collection, even if the table itself is displaying only a subset of those attributes.