How to Add a panelCollection with a Table, Tree, or Tree Table

10-48 Web User Interface Developers Guide for Oracle Application Development Framework Figure 10–25 Exported Data File in Excel

10.9.1 How to Export Table, Tree, or Tree Table Data to an External Format

You create a command component, such as a button, link, or menu item, and add the exportCollectionActionListener inside this component. Then you associate the data collection you want to export by setting the exportCollectionActionListener component’s exportedId attribute to the ID of the collection component whose data you wish to export. Before you begin: You should already have a table, tree, or tree table on your page. If you do not, follow the instructions in this chapter to create a table, tree, or tree table. For example, to add a table, see Section 10.2, Displaying Data in Tables. To export collection data to an external format: 1. In the Component Palette, from the Common Components panel, drag and drop a command component, such as a button, to your page. You may want to change the default label of the command component to a meaningful name such as Export to Excel.

2. In the Component Palette, from the Operations panel, drag an Export Collection

Action Listener as a child to the command component.

3. In the Insert Export Collection Action Listener dialog, set the following:

Note: You may receive a warning from Excel stating that the file is in a different format than specified by the file extension. This warning can be safely ignored. Tip: If you want users to be able to select rows to export, then configure your table to allow selection. For more information, see Section 10.2.2, Formatting Tables. Tip: If you want your table, tree, or tree table to have a toolbar that will hold command components, you can wrap the collection component in a panelCollection component. This component adds toolbar functionality. For more information, see Section 10.8, Displaying Table Menus, Toolbars, and Status Bars. Using Tables and Trees 10-49 ■ ExportedId : Specify the ID of the table, tree, or tree table to be exported. Either enter it manually or use the dropdown menu to choose Edit. Use the Edit Property dialog to select the component. ■ Type : Set to excelHTML. 4. With the exportCollectionActionListener component still selected, in the Property Inspector, set the following: ■ Filename : Specify the proposed file name for the exported content. When this attribute is set, a Save File dialog will typically be displayed, though this is ultimately up to the browser. If the attribute is not set, the content will typically be displayed inline, in the browser, if possible. ■ Title : Specify the title of the exported document. Whether or not the title is displayed and how exactly it is displayed depends on Excel. ■ ExportedRows : Set to all if you want all rows to be automatically selected and exported. Set to selected if you want only the rows the user has selected to be exported. Example 10–21 shows the code for a table and its exportCollectionActionListener component. Note that the exportedId value is set to the table id value. Example 10–21 Using the exportCollectionActionListener to Export a Table af:table contextMenuId=thePopup selectionListener={fs.Table} rowselection=multiple columnselection=multiple columnBandingInterval=1 binding={editor.component} var=test1 value={tableTestData} id=table summary=table data af:column . . . af:column af:table af:commandButton text=Export To Excel immediate=true af:exportCollectionActionListener type=excelHTML exportedId=table filename=export.xls title=ADF Faces Export

10.9.2 What Happens at Runtime: How Row Selection Affects the Exported Data

Exported data is exported in index order, not selected key order. This means that if you allow selected rows to be exported, and the user selects rows in this order 8, 4, and 2, then the rows will be exported and displayed in Excel in the order 2, 4, 8.

10.10 Accessing Selected Values on the Client from Components That Use Stamping

Since there is no client-side support for EL in the rich client framework, nor is there support for sending entire table models to the client, if you need to access values on the client using JavaScript, the client-side code cannot rely on component stamping to access the value. Instead of reusing the same component instance on each row, a new JavaScript component is created on each row assuming any component needs to be created at all for any of the rows, using the fully resolved EL expressions.