Drag the collection onto a JSF page, and from the context menu, choose the The ensuing Edit Table Columns dialog shows each attribute in the collection, and

4-2 Java EE Developers Guide for Oracle Application Development Framework correct data for each object, while the table component handles displaying each object in a row. JDeveloper allows you to do this declaratively, so that you don’t need to write any code.

4.2.1 How to Create a Basic Table

To create a table using a data control, you bind the table component to a returned collection. JDeveloper allows you to do this declaratively by dragging and dropping a collection from the Data Controls panel. To create a databound table: 1. From the Data Controls panel, select a collection. For example, to create a simple table in the Suppler module that displays products in the system, you would select the productFindAll accessor collection.

2. Drag the collection onto a JSF page, and from the context menu, choose the

appropriate table. When you drag the collection, you can choose from the following types of tables: ■ ADF Table : Allows you to select the specific attributes you need your editable table columns to display, and what UI components to use to display the data. By default, ADF inputText components are used for most attributes, thus enabling the table to be editable. Attributes that are dates use the inputDate component. Additionally, if a control type control hint has been created for an attribute, or if the attribute has been configured to be a list, then the component set by the hint is used instead. For more information about setting control hints, see the Defining Attribute Control Hints for View Objects section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework ■ ADF Read-Only Table: Same as the ADF Table; however, each attribute is displayed in an outputText component. ■ ADF Read-Only Dynamic Table : Allows you to create a table when the attributes returned and displayed are determined dynamically at runtime. This component is helpful when the attributes for the corresponding object are not known until runtime, or you do not wish to hardcode the column names in the JSF page.

3. The ensuing Edit Table Columns dialog shows each attribute in the collection, and

allows you to determine how these attributes will behave and appear as columns in your table. Using this dialog, you can do the following: Tip: You can also create a table by dragging a table component from the Component Palette and completing the Create ADF Faces Table wizard. For more information, see the How to Display a Table on a Page section of the Oracle Fusion Middleware Web User Interface Developers Guide for Oracle Application Development Framework. Note: If the collection contains a structured attribute an attribute that is neither a Java primitive type nor a collection, the attributes of the structured attributes will also appear in the dialog. Creating ADF Databound Tables 4-3 ■ Allow the ADF Model layer to handle selection by selecting the Row Selection checkbox. Selecting this option means that the iterator binding will access the iterator to determine the selected row. Select this option unless you do not want the table to allow selection. ■ Allow the ADF Model layer to handle column sorting by selecting the Sorting checkbox. Selecting this option means that the iterator binding will access the iterator, which will perform an order-by query to determine the order. Select this option unless you do not want to allow column sorting. ■ Allow the columns in the table to be filtered using entered criteria by selecting the Filtering checkbox. Selecting this option allows the user to enter criteria in text fields above each column. That criteria is then used to build a Query-by-Example QBE search on the collection, so that the table will display only the results returned by the query. For more information, see Section 7.5, Creating Standalone Filtered Search Tables. ■ Group columns for selected attributes together under a parent column, by selecting the desired attributes shown as rows in the dialog, and clicking the Group button. Figure 4–2 shows how two grouped columns appear in the visual editor after the table is created. Figure 4–2 Grouped Columns in an ADF Faces Table ■ Change the display label for a column by entering text or an EL expression to bind the label value to something else, for example, a key in a resource file. By default, the label is bound to the labels property for any control hint defined for the attribute on the table binding. This binding allows you to change the value of a label text one time in the structure file, and have the change propagate to all pages that display the label. ■ Change the value binding for a column by selecting a different attribute to bind to. If you simply want to rearrange the columns, you should use the order buttons. If you do change the attribute binding for a column, the label for the column also changes. ■ Change the UI component used to display an attribute using the dropdown menu. The UI components are set based on the table you selected when you dropped the collection onto the page, on the type of the corresponding attribute for example, inputDate components are used for attributes that are dates, and on whether or not default components were set as control hints in the Java class’s structure file. Tip: If one of the attributes for your table is also a primary key, you may want to choose a UI component that will not allow a user to change the value. Tip: If you want to use a component that is not listed in the dropdown menu, use this dialog to select the outputText component, and then manually add the other tag to the page. 4-4 Java EE Developers Guide for Oracle Application Development Framework ■ Change the order of the columns using the order buttons. ■ Add a column using the Add icon. There’s no limit to the number of columns you can add. When you first click the icon, JDeveloper adds a new column line at the bottom of the dialog and populates it with the values from the first attribute in the bound collection; subsequent new columns are populated with values from the next attribute in the sequence, and so on. ■ Delete a column using the Delete icon. 4. Once the table is dropped on the page, you can use the Property Inspector to set other display properties of the table. For example, you may want to set the width of the table to a certain percentage or size. For more information about display properties, see the Using Tables and Trees chapter of the Oracle Fusion Middleware Web User Interface Developers Guide for Oracle Application Development Framework. 5. If you want the user to be able to edit information in the table and save any changes, you need to provide a way to submit and persist those changes. For more information, see Section 4.3, Creating an Editable Table. For procedures on creating tables that allow users to input data, see Section 4.4, Creating an Input Table.

4.2.2 What Happens When You Create a Table