What You May Need to Know About Temporary File Storage

10 Using Tables and Trees 10-1 10 Using Tables and Trees This chapter describes how to display tables and trees using the ADF Faces table, tree and treeTable components. If your application uses the Fusion technology stack, then you can use data controls to create tables and trees. For more information see the Creating ADF Databound Tables and Displaying Master-Detail Data chapters of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework This chapter includes the following sections: ■ Section 10.1, Introduction to Tables, Trees, and Tree Tables ■ Section 10.2, Displaying Data in Tables ■ Section 10.3, Adding Hidden Capabilities to a Table ■ Section 10.4, Enabling Filtering in Tables ■ Section 10.5, Displaying Data in Trees ■ Section 10.6, Displaying Data in Tree Tables ■ Section 10.7, Passing a Row as a Value ■ Section 10.8, Displaying Table Menus, Toolbars, and Status Bars ■ Section 10.9, Exporting Data from Table, Tree, or Tree Table ■ Section 10.10, Accessing Selected Values on the Client from Components That Use Stamping

10.1 Introduction to Tables, Trees, and Tree Tables

Structured data can be displayed as tables consisting of rows and columns using the ADF Faces table component. Hierarchical data can be displayed either as tree structures using ADF Faces tree component, or in a table format, using ADF Faces tree table component. Instead of containing a child component for each record to be displayed, and then binding these components to the individual records, table, tree and tree table components are bound to a complete collection, and they then repeatedly render one component for example an outputText component by stamping the value for each record. For example, say a table contains two child column components. Each column displays a single attribute value for the row using an output component and there are four records to be displayed. Instead of binding four sets of two output components to display the data, the table itself is bound to the collection of all four records and simply stamps one set of the output components four times. As each row is stamped, the data for the current row is copied into the var attribute on the table, from which the output component can retrieve the correct values for the row. For more information about how stamping works, especially with client 10-2 Web User Interface Developers Guide for Oracle Application Development Framework components, see Section 10.1.5, Accessing Client Table, Tree, and Tree Table Components. Example 10–1 shows the JSF code for a table whose value for the var attribute is row. Each outputText component in a column displays the data for the row because its value is bound to a specific property on the variable. Example 10–1 JSF Code for a Table Uses the var Attribute to Access Values af:table var=row value={myBean.allEmployees} af:column af:outputText value={row.firstname} af:column af:column af:outputText value={row.lastname} af:column af:table The table component displays simple tabular data. Each row in the table displays one object in a collection, for example one row in a database. The column component displays the value of attributes for each of the objects. For example, as shown in Figure 10–1 , the Table tab in the File Explorer application uses a table to display the contents of the selected directory. The table value attribute is bound to the contentTable property of the tableContentView managed bean in the File Explorer demo. Figure 10–1 Table Component in the File Explorer Application The table component provides a range of features for end users, such as sorting columns, and selecting one or more rows and then executing an application defined action on the selected rows. It also provides a range of presentation features, such as showing grid lines and banding, row and column headers, column headers spanning groups of columns, and values wrapping within cells. Hierarchical data that is data that has parentchild relationships, such as the directory in the File Explorer application, can be displayed as expandable trees using the tree component. Items are displayed as nodes that mirror the parentchild structure of the data. Each top-level node can be expanded to display any child nodes, which in turn can also be expanded to display any of their child nodes. Each expanded node can then be collapsed to hide child nodes. Figure 10–2 shows the file directory in the File Explorer application, which is displayed using a tree component. Using Tables and Trees 10-3 Figure 10–2 Tree Component in the File Explorer Application Hierarchical data can also be displayed using tree table components. The tree table also displays parentchild nodes that are expandable and collapsible, but in a tabular format, which allows the page to display attribute values for the nodes as columns of data. For example, along with displaying a directory’s contents using a table component, the File Explorer application has another tab that uses the tree table component to display the contents, as shown in Figure 10–3 . Figure 10–3 Tree Table in the File Explorer Application Like the tree component, the tree table component can show the parentchild relationship between items. And like the table component, the tree table component can also show any attribute values for those items in a column. Most of the features available on a table component are also available in tree table component. You can add a toolbar and a status bar to tables, trees, and tree tables by surrounding them with the panelCollection component. The top panel contains a standard menu bar as well as a toolbar that holds menu-type components such as menus and menu options, toolbars and toolbar buttons, and status bars. Some buttons and menus are added by default. For example, when you surround a table, tree, or tree table with a panelCollection component, a toolbar that contains the View menu is added. This menu contains menu items that are specific to the table, tree, or tree table component. Figure 10–4 shows the tree table from the File Explorer application with the toolbar, menus, and toolbar buttons created using the panelCollection component. 10-4 Web User Interface Developers Guide for Oracle Application Development Framework Figure 10–4 TreeTable with Panel Collection

10.1.1 Content Delivery

The table, tree, and tree table components are virtualized, meaning not all the rows that are there for the component on the server are delivered to and displayed on the client. You configure tables, trees, and tree tables to fetch a certain number of rows at a time from your data source. The data can be delivered to the components immediately upon rendering, when it is available, or lazily fetched after the shell of the component has been rendered by default, the components fetch data when it is available. With immediate delivery, the data is fetched during the initial request. With lazy delivery, when a page contains one or more table or tree components, the page initially goes through the standard lifecycle. However, instead of fetching the data during that initial request, a special separate partial page rendering PPR request is run, and the number of rows set as the value of the fetch size for the table is then returned. Because the page has just been rendered, only the Render Response phase executes for the components, allowing the corresponding data to be fetched and displayed. When a user’s actions cause a subsequent data fetch for example scrolling in a table for another set of rows, another PPR request is executed. When content delivery is configured to be delivered when it is available, the framework checks for data availability during the initial request, and if it is available, it sends the data to the table. If it is not available, the data is loaded during the separate PPR request, as it is with lazy delivery. Performance Tip: Lazy delivery should be used when a data fetch is expected to be an expensive slow operation, for example, slow, high-latency database connection, or fetching data from slow non-database data sources like web services. Lazy delivery should also be used when the page contains a number of components other than a table, tree, or tree table. Doing so allows the initial page layout and other components to be rendered first before the data is available. Immediate delivery should be used if the table, tree, or tree table is the only context on the page, or if the component is not expected to return a large set of data. In this case, response time will be faster than using lazy delivery or in some cases, simply perceived as faster, as the second request will not go to the server, providing a faster user response time and better server CPU utilizations. Note however that only the number of rows configured to be the fetch block will be initially returned. As with lazy delivery, when a user’s actions cause a subsequent data fetch, the next set of rows are delivered. When available delivery provides the additional flexibility of using immediate when data is available during initial rendering or falling back on lazy when data is not initially available.