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

Using Tables and Trees 10-51 JavaScript object that contains properties for each selected row key. Once you have access to this object, you can iterate over the row keys using a for in loop. For example, the code in Example 10–24 extracts the first row key which in this case, is the only row key. Example 10–24 Iterating Over Row Keys Using a for in Loop function showSelectedNameevent { var firstRowKey; var addRowKeys=event.getAddedSet; forvar rowKey in addedRowKeys { firstRowKey=rowKey; break; } } ■ Find the stamped component associated with the selected row. The client-side component API AdfUIComponent exposes a findComponent method that takes the ID of the component to find and returns the AdfUIComponent instance. When using stamped components, you need to find a component not just by its ID, but by the row key as well. In order to support this, the AdfUITable class provides an overloaded method of findComponent, which takes both an ID as well as a row key. In the case of selection events, the component is the source of the event. So you can get the table from the source of the event and then use the table to find the instance using the ID and row key. Example 10–25 shows this, where nameStamp is the ID of the table. Example 10–25 Finding a Stamped Component Instance Given a Selected Row We need the table to find our stamped component. Fortunately, in the case of selection events, the table is the event source. var table = event.getSource; Use the table to find the name stamp component by idrow key: var nameStamp = table.findComponentnameStamp, firstRowKey; 5. Add any additional code needed to work with the component. Once you have the stamped component, you can interact with it as you would with any other component. For example, Example 10–26 shows how to use the stamped component to get the row-specific value of the name attribute which was the stamped value as shown in Example 10–22 and then display the name in an alert. Example 10–26 Retrieving the Name of the Row in a Stamped Component if nameStamp { This is the row-specific name var name = nameStamp.getValue; alertThe selected name is: + name; } Example 10–27 shows the entire code for the JavaScript. 10-52 Web User Interface Developers Guide for Oracle Application Development Framework Example 10–27 JavaScript Used to Access Selected Row Value function showSelectedNameevent { var firstRowKey; var addedRowKeys = event.getAddedSet; for var rowKey in addedRowKeys { firstRowKey = rowKey; break; } We need the table to find our stamped component. Fortunately, in the case of selection events, the table is the event source. var table = event.getSource; We use the table to find the name stamp component by idrow key: var nameStamp = table.findComponentnameStamp, firstRowKey; if nameStamp { This is the row-specific name var name = nameStamp.getValue; alertThe selected name is: + name; } }

10.10.2 What You May Need to Know About Accessing Selected Values

Row keys are tokenized on the server, which means that the row key on the client may have no resemblance to the row key on the server. As such, only row keys that are served up by the client-side APIs like AdfSelectionEvent.getAddedSet are valid. Also note that AdfUITable.findComponentid, rowKeymethod may return null if the corresponding row has been scrolled off screen and is no longer available on the client. Always check for null return values from AdfUITable.findComponent method.