First page Back Continue Last page Graphics

Using Table Model Methods in a Selection Listener


Using Table Model Methods in a Selection Listener

The ADF Faces table components use a model to access the data in the underlying list. The specific model class is You may also use other model instances, such as java.util.List, java.util.Array, and javax.faces.model.DataModel. If you use one of these other classes, the table component automatically converts the instance into a CollectionModel.

You can use table model methods, for example, in a method called by a selection listener on the table. You can programmatically manipulate the table in the following ways:

To make a row current, call setRowIndex() with the appropriate index into the list or with the appropriate rowKey.

To access a particular row in the list, first make that row current, and then call the getRowData() method on the table.

To obtain the total number of rows in the list, call getRowCount(); if the model does not yet know the total number of rows that are available, getRowCount() returns -1.

The table has an isRowAvailable() method that returns true if the current row is available. This method is especially useful when the total number of rows is unknown.

You cannot use af:forEach to iterate over data within a table component; you can use af:iterator instead.