Using Popup Dialogs in Tables, Trees, and Tree Tables

10-10 Web User Interface Developers Guide for Oracle Application Development Framework Figure 10–7 Table Stretches But Columns Do Not When placed in a component that does not stretch its children for example, in a panelCollection component inside a panelGroupLayout component set to vertical, by default, a table width is set to 300px, as shown in Figure 10–8 . Figure 10–8 Table Does Not Stretch When you place a table in a component that does not stretch its children, you can control the height of the table so that is never more than a specified number of rows, using the autoHeightRows attribute. When you set this attribute to a positive Using Tables and Trees 10-11 integer, the table height will be determined by the number of rows set. If that number is higher than the fetchSize attribute, then only the number of rows in the fetchSize attribute will be returned. You can set autoHeightRows to -1 the default, to turn off auto-sizing. Auto-sizing can be helpful in cases where you want to use the same table both in components that stretch their children and those that don’t. For example, say you have a table that has 6 columns and can potentially display 12 rows. When you use it in a component that stretches its children, you want the table to stretch to fill the available space. If you want to use that table in a component that doesn’t stretch its children, you want to be able to fix the height of the table. However, if you set a height on the table, then that table will not stretch when placed in the other component. To solve this issue, you can set the autoHeightRows attribute, which will be ignored when in a component that stretches, and will be honored in one that does not.

10.2 Displaying Data in Tables

The table component uses a CollectionModel class to access the data in the underlying collection. This class extends the JSF DataModel class and adds on support for row keys and sorting. In the DataModel class, rows are identified entirely by index. This can cause problems when the underlying data changes from one request to the next, for example a user request to delete one row may delete a different row when another user adds a row. To work around this, the CollectionModel class is based on row keys instead of indexes. You may also use other model classes, such as java.util.List, array, and javax.faces.model.DataModel. If you use one of these other classes, the table component automatically converts the instance into a CollectionModel class, but without the additional functionality. For more information about the CollectionModel class, see the MyFaces Trinidad Javadoc at http:myfaces.apache.orgtrinidadtrinidad-1_ 2trinidad-apiapidocsindex.html . The immediate children of a table component must be column components. Each visible column component is displayed as a separate column in the table. Column components contain components used to display content, images, or provide further functionality. For more information about the features available with the column component, see Section 10.2.1, Columns and Column Data. The child components of each column display the data for each row in that column. The column does not create child components per row; instead, the table uses stamping to render each row. Each child is stamped once per row, repeatedly for all the rows. As each row is stamped, the data for the current row is copied into a property that can be addressed using an EL expression. You specify the name to use for this property using the var property on the table. Once the table has completed rendering, this property is removed or reverted back to its previous value. Because of this stamping behavior, some components may not work inside the column. Most components will work without problems, for example any input and output components. If you need to use multiple components inside a cell, you can Note: If your application uses the Fusion technology stack, then you can use data controls to create tables and the collection model will be created for you. For more information see the Creating ADF Databound Tables chapter of the Oracle Fusion Middleware Web User Interface Developers Guide for Oracle Application Development Framework. 10-12 Web User Interface Developers Guide for Oracle Application Development Framework wrap them inside a panelGroupLayout component. Components that themselves support stamping are not supported, such as tables within a table. For information about using components whose values are determined dynamically at runtime, see Section 10.2.9, What You May Need to Know About Dynamically Determining Values for Selection Components in Tables. You can use the detailStamp facet in a table to include data that can be optionally displayed or hidden. When you add a component to this facet, the table displays an additional column with an expand and collapse icon for each row. When the user clicks the icon to expand, the component added to the facet is displayed, as shown in Figure 10–9 . Figure 10–9 Extra Data Can Be Optionally Displayed When the user clicks on the expanded icon to collapse it, the component is hidden, as shown in Figure 10–10 . Figure 10–10 Extra Data Can Be Hidden For more information about using the detailStamp facet, see Section 10.3, Adding Hidden Capabilities to a Table.

10.2.1 Columns and Column Data

Columns contain the components used to display the data. As stated previously, only one child component is needed for each item to be displayed; the values are stamped as the table renders. Columns can be sorted and can also contain a filtering element. Users can enter a value into the filter and the returned data set will match the value entered in the filter. You can set the filter to be either case-sensitive or case-insensitive. If the table is configured to allow it, users can also reorder columns. Columns have both header and footer facets. The header facet can be used instead of using the header text attribute of the column, allowing you to use a component that can be styled. The footer facet is displayed at the bottom of the column. For example, Figure 10–11 uses footer facets to display the total at the bottom of two columns. If the number of rows returned is more than can be displayed, the footer facet is still displayed; the user can scroll to the bottom row.