Class DataModel<E>

java.lang.Object
jakarta.faces.model.DataModel<E>
All Implemented Interfaces:
Iterable<E>
Direct Known Subclasses:
ArrayDataModel, CollectionDataModel, IterableDataModel, ListDataModel, ResultSetDataModel, ScalarDataModel

public abstract class DataModel<E> extends Object implements Iterable<E>

DataModel is an abstraction around arbitrary data binding technologies that can be used to adapt a variety of data sources for use by Jakarta 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.