Row Selection Introduction to Tables, Trees, and Tree Tables

10-8 Web User Interface Developers Guide for Oracle Application Development Framework components automatically establish the currency to the row for which the context menu is being displayed. Establishing currency means that the current row in the model for the table now points to the row for which the context menu is being displayed. In order for this to happen, the popup component containing the menu must have its contentDelivery attribute set to lazyUncached so that the menu is fetched every time it is displayed. Tip: If you want the context menu to dynamically display content based on the selected row, set the popup content delivery to lazyUncached and add a setPropertyListener tag to a method on a managed bean that can get the current row and then display data based on the current row: af:tree value={fs.treeModel} contextMenuSelect=false var=node .. f:facet name=contextMenu af:popup id=myPopup contentDelivery=lazyUncached af:setPropertyListener from={fs.treeModel.rowData} to={dynamicContextMenuTable.currentTreeRowData} type=popupFetch af:menu af:menu text=Node Info Dynamic af:commandMenuItem actionListener= {dynamicContextMenuTable.alertTreeRowData} text= Name - {dynamicContextMenuTable.currentTreeRowData.name} af:commandMenuItem actionListener= {dynamicContextMenuTable.alertTreeRowData} text= Path - {dynamicContextMenuTable.currentTreeRowData.path} af:commandMenuItem actionListener= {dynamicContextMenuTable.alertTreeRowData} text=Date - {dynamicContextMenuTable.currentTreeRowData.lastModified} af:menu af:menu af:popup f:facet ... af:tree The code on the backing bean might look something like this: public class DynamicContextMenuTableBean { ... public void setCurrentTreeRowDataMap currentTreeRowData { _currentTreeRowData = currentTreeRowData; } public Map getCurrentTreeRowData { return _currentTreeRowData; } private Map _currentTreeRowData; } Using Tables and Trees 10-9 Tables and tree tables contain the bodyContextMenu facet. You can add a popup that contains a menu to this facet, and it will be displayed whenever a user clicks on the table, but not within a specific row. For more information about creating context menus, see Section 13.2, Declaratively Creating Popup Elements.

10.1.5 Accessing Client Table, Tree, and Tree Table Components

With ADF Faces, the contents of the table, tree, or tree table are rendered on the server. There may be cases when the client needs to access that content on the server, including: ■ Client-side application logic may need to read the row-specific component state. For example, in response to row selection changes, the application may want to update the disabled or visible state of other components in the page usually menu items or toolbar buttons. This logic may be dependent on row-specific metadata sent to the client using a stamped inputHidden component. In order to enable this, the application must be able to retrieve row-specific attribute values from stamped components. ■ Client-side application logic may need to modify row-specific component state. For example, clicking a stamped command link in a table row may update the state of other components in the same row. ■ The peer may need access to a component instance to implement event handling behavior for more information about peers, see Section 3.1, Introduction to Using ADF Faces Architecture . For example, in order to deliver a client-side action event in response to a mouse click, the AdfDhtmlCommandLinkPeer class needs a reference to the component instance which will serve as the event source. The component also holds on to relevant state, including client listeners as well as attributes that control event delivery behavior, such as disabled or partialSubmit. Because there is no client-side support for EL in the rich client framework RCF, nor is there support for sending entire table models to the client, 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 client component is created on each row assuming any component must be created at all for any of the rows. Therefore, to access row-specific data on the client, you need to use the stamped component itself to access the value. To do this without a client-side data model, you use a client-side selection change listener. For detailed instructions, see Section 10.10, Accessing Selected Values on the Client from Components That Use Stamping.

10.1.6 Geometry Management and Table, Tree, and Tree Table Components

By default, when tables, trees, and tree tables are placed in a component that stretches its children for example, a panelCollection component inside a panelStretchLayout component, the table, tree, or tree table will stretch to fill the existing space. However, in order for the columns to stretch to fit the table, you must specify a specific column to stretch to fill up any unused space, using the columnStretching attribute. Otherwise, the table will only stretch vertically to fit as many rows as possible. It will not stretch the columns, as shown in Figure 10–7 .