DataModel
is an abstraction around arbitrary data
binding technologies that can be used to adapt a variety of data sources
for use by JavaServer Faces components that support per-row processing
for their child components (such as UIData.
The data collection underlying a DataModel instance is
modeled as a collection of row objects that can be accessed by
a zero-relative cursor (row index). The APIs provide mechanisms to
position to a specified zero-relative row index, and to retrieve an
object that represents the data that corresponds to the current
row index.
A concrete DataModel instance is attached to a particular
collection of underlying data by calling the setWrappedData()
method. It can be detached from that underlying data collection by
passing a null parameter to this method.
Concrete DataModel implementations must provide a public
zero-arguments constructor that calls setWrappedData(null).
A convenience constructor that takes a wrapped object of the appropriate
type (and passes it on via a call to setWrappedData(),
should also be provided.
Event listeners may be registered to receive notifications of when a new row index is selected.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final DataModelListener[] | |
| private List | listeners
The list of registered |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addDataModelListener(DataModelListener
The new listener)DataModelListener to be registeredAdd a new |
| public DataModelListener[] | Returns: the listeners for this instance, or an empty arrayReturn the set of |
| public abstract int | Returns: the number of rows of data represented by thisDataModelReturn the number of rows of data objects represented by this
|
| public abstract E | Returns: an object representing the data for the currently selected row indexReturn an object representing the data for the currently selected row index. |
| public abstract int | Returns: the index of the currently selected rowReturn the zero-relative index of the currently selected row. |
| public abstract Object | Returns: theObject that this model wraps.Return the object representing the data wrapped by this
|
| public abstract boolean | Returns: true if and only if there is data available at the current index, false otherwise.Return a flag indicating whether there is |
| public Iterator | iterator()
Implements java. Return a read-only |
| public void | removeDataModelListener(DataModelListener
The old listener)DataModelListener to be deregisteredRemove an existing |
| public abstract void | setRowIndex(int
The new zero-relative index (must be non-negative) rowIndex)Set the zero-relative index of the currently selected row, or -1 to indicate that we are not positioned on a row. |
| public abstract void | setWrappedData(Object
Data collection to be wrapped, or data)null to
detach from any previous data collectionSet the object representing the data collection wrapped by this
|
| EMPTY_DATA_MODEL_LISTENER | back to summary |
|---|---|
| private static final DataModelListener[] EMPTY_DATA_MODEL_LISTENER | |
| listeners | back to summary |
|---|---|
| private List<DataModelListener> listeners The list of registered | |
| DataModel | back to summary |
|---|---|
| public DataModel() | |
| addDataModelListener | back to summary |
|---|---|
| public void addDataModelListener(DataModelListener listener) Add a new
| |
| getDataModelListeners | back to summary |
|---|---|
| public DataModelListener[] getDataModelListeners() Return the set of
| |
| getRowCount | back to summary |
|---|---|
| public abstract int getRowCount() Return the number of rows of data objects represented by this
| |
| getRowData | back to summary |
|---|---|
| public abstract E getRowData() Return an object representing the data for the currently selected
row index. If no
| |
| getRowIndex | back to summary |
|---|---|
| public abstract int getRowIndex() Return the zero-relative index of the currently selected row. If
we are not currently positioned on a row, or no
| |
| getWrappedData | back to summary |
|---|---|
| public abstract Object getWrappedData() Return the object representing the data wrapped by this
| |
| isRowAvailable | back to summary |
|---|---|
| public abstract boolean isRowAvailable() Return a flag indicating whether there is
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Return a read-only
| |
| removeDataModelListener | back to summary |
|---|---|
| public void removeDataModelListener(DataModelListener listener) Remove an existing
| |
| setRowIndex | back to summary |
|---|---|
| public abstract void setRowIndex(int rowIndex) Set the zero-relative index of the currently selected row, or -1
to indicate that we are not positioned on a row. It is
possible to set the row index at a value for which the underlying data
collection does not contain any row data. Therefore, callers may
use the If there is no
| |
| setWrappedData | back to summary |
|---|---|
| public abstract void setWrappedData(Object data) Set the object representing the data collection wrapped by this
If
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public T | |
| public void |
| DataModelIterator | back to summary |
|---|---|
| pack-priv DataModelIterator(DataModel<T> model) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Unsupported.
| |