public abstract class DataModel<E> extends Object implements Iterable<E>
Note that DataModel and its standard subclasses are not serializable, as there is no state in a DataModel object itself that needs to be preserved between render and restore-view. UIData components therefore do not store their DataModel when serialized; they just evaluate their "value" EL expression to refetch the object during the apply-request-values phase.
Because DataModel is not serializable, any managed bean that needs to be serialized and which has a member of type DataModel should therefore mark that member transient. If there is a need to preserve the datalist contained within the DataModel then ensure a reference to that list is stored in a non-transient member, or use a custom serialization method that explicitly serializes dataModel.getWrappedData. See Javadoc of JSF Specification for more.
Constructor and Description |
---|
DataModel() |
Modifier and Type | Method and Description |
---|---|
void |
addDataModelListener(DataModelListener listener) |
DataModelListener[] |
getDataModelListeners() |
abstract int |
getRowCount()
Return the number of rows of data available.
|
abstract E |
getRowData()
Return the object associated with the current row index.
|
abstract int |
getRowIndex()
Get the current row index.
|
abstract Object |
getWrappedData()
Get the entire collection of data associated with this component.
|
abstract boolean |
isRowAvailable()
Returns true if a call to getRowData will return a valid object.
|
Iterator<E> |
iterator() |
void |
removeDataModelListener(DataModelListener listener) |
abstract void |
setRowIndex(int rowIndex)
Set the current row index.
|
abstract void |
setWrappedData(Object data)
Set the entire list of data associated with this component.
|
public void addDataModelListener(DataModelListener listener)
public DataModelListener[] getDataModelListeners()
public abstract int getRowCount()
Return the number of rows of data available.
If the number of rows of data available is not known then -1 is returned. This may happen for DataModels that wrap sources of data such as java.sql.ResultSet that provide an iterator to access the "next item" rather than a fixed-size collection of data.
public abstract E getRowData()
Method isRowAvailable may be called before attempting to access this method, to ensure that the data is available.
RuntimeException
- subclass of some kind if the current row index
is not within the range of the current wrappedData property.public abstract int getRowIndex()
public abstract Object getWrappedData()
public abstract boolean isRowAvailable()
public void removeDataModelListener(DataModelListener listener)
public abstract void setRowIndex(int rowIndex)
rowIndex
- The row index. It may be -1 to indicate "no row",
or may be a value between 0 and getRowCount()-1.public abstract void setWrappedData(Object data)
data
- The object to be wrapped.Copyright © 2016 The Apache Software Foundation. All Rights Reserved.