|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
javax.faces.model.DataModel
org.apache.myfaces.trinidad.model.CollectionModel
public abstract class CollectionModel
The data model that is used by the Trinidad Table and Iterator components. This extends the Faces DataModel class and adds on support for rowKeys and sorting. Ordinary DataModels are still supported, and will automatically be wrapped into CollectionModels, but without the added functionality.
In the Faces DataModel, rows are identified entirely by index. This causes major problems if the underlying data changes from one request to the next - a user request to delete one row may delete a different row because a row got added by another user, etc. To work around this, CollectionModel is based around row keys instead of indices. An implementation of CollectionModel must implement getRowKey() and setRowKey(), and handle conversion from integer indices to row keys. A trivial implementation might simply use Integer objects as the row keys, but a better version could use a unique ID in the row.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.apache.myfaces.trinidad.model.LocalRowKeyIndex |
|---|
LocalRowKeyIndex.Confidence, LocalRowKeyIndex.LocalCachingStrategy |
| Constructor Summary | |
|---|---|
CollectionModel() |
|
| Method Summary | |
|---|---|
boolean |
areRowsLocallyAvailable(int rowsToCheck)Check if a range of rows is locally available starting from current position. |
boolean |
areRowsLocallyAvailable(int startIndex, int rowsToCheck)Check if a range of rows is locally available starting from a row index. |
boolean |
areRowsLocallyAvailable(java.lang.Object startRowKey, int rowsToCheck)Check if a range of rows is locally available starting from a row key. |
void |
clearCachedRow(int index)Clears the row with the given index from local cache. |
void |
clearCachedRow(java.lang.Object rowKey)Clears the row with the given row key from local cache. |
void |
clearCachedRows(int startingIndex, int rowsToClear)Clears a range of rows from local cache starting from a row index. |
void |
clearCachedRows(java.lang.Object startingRowKey, int rowsToClear)Clears a range of rows from local cache starting from a row key This is a do nothing implemenation. |
void |
clearLocalCache()Clears the local cache. |
void |
ensureRowsAvailable(int rowCount)Ensure that the model has at least rowCount number of rows. |
LocalRowKeyIndex.LocalCachingStrategy |
getCachingStrategy()Returns the row caching strategy used by this implemenation. |
int |
getEstimatedRowCount()Convenient API to return a row count estimate. |
LocalRowKeyIndex.Confidence |
getEstimatedRowCountConfidence()Helper API to determine if the row count returned from getEstimatedRowCount() is EXACT, or an ESTIMATE. |
java.lang.Object |
getRowData(int rowIndex)Gets the rowData at the given index. |
java.lang.Object |
getRowData(java.lang.Object rowKey)Returns the rowData for the given rowKey without changing model currency. |
abstract java.lang.Object |
getRowKey()Gets the rowKey of the current row. |
java.util.List<SortCriterion> |
getSortCriteria()Gets the criteria that this collection is sorted by. |
boolean |
isRowAvailable(int rowIndex)Checks to see if the row at the given index is available. |
boolean |
isRowLocallyAvailable(int rowIndex)Given a row index, check if the row is locally available. |
boolean |
isRowLocallyAvailable(java.lang.Object rowKey)Given a row key, check if the row is locally available. |
boolean |
isSortable(java.lang.String property)Return true if this collection is sortable by the given property. |
abstract void |
setRowKey(java.lang.Object key)Finds the row with the matching key and makes it current |
void |
setSortCriteria(java.util.List<SortCriterion> criteria)Sorts this collection by the given criteria. |
| Methods inherited from class javax.faces.model.DataModel |
|---|
addDataModelListener, getDataModelListeners, getRowCount, getRowData, getRowIndex, getWrappedData, isRowAvailable, removeDataModelListener, setRowIndex, setWrappedData |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.myfaces.trinidad.model.RowKeyIndex |
|---|
getRowCount, getRowData, getRowIndex, isRowAvailable, setRowIndex |
| Constructor Detail |
|---|
public CollectionModel()
| Method Detail |
|---|
public abstract java.lang.Object getRowKey()
Object.equals(java.lang.Object) and Object.hashCode() as they will be used as keys in hashtables. rowKeys should also be Serializable, so that the application can run under all JSF state-saving schemes.getRowKey in interface RowKeyIndexsetRowKey(java.lang.Object)public abstract void setRowKey(java.lang.Object key)
setRowKey in interface RowKeyIndexkey - the rowKey, previously obtained from getRowKey().public boolean isRowAvailable(int rowIndex)
DataModel.isRowAvailable(). Finally, the row that was current before this method was called is made current again.isRowAvailable in interface RowKeyIndexrowIndex - the index of the row to check.DataModel.isRowAvailable()public java.lang.Object getRowData(int rowIndex)
DataModel.getRowData(). Finally, the row that was current before this method was called is made current again.getRowData in interface RowKeyIndexrowIndex - the index of the row to get data from.DataModel.getRowData()public java.lang.Object getRowData(java.lang.Object rowKey)
rowKey - the row key of the row to get data from.DataModel.getRowData()public boolean isSortable(java.lang.String property)
public java.util.List<SortCriterion> getSortCriteria()
SortCriterionpublic void setSortCriteria(java.util.List<SortCriterion> criteria)
criteria - Each element in this List must be of type SortCriterion. The empty list may be used to cancel any sort order. null should be treated the same as an empty list.SortCriterion
public boolean areRowsLocallyAvailable(int startIndex,
int rowsToCheck)
areRowsLocallyAvailable in interface LocalRowKeyIndexstartIndex - starting row index to checkrowsToCheck - number of rows to checkfalse
public boolean areRowsLocallyAvailable(java.lang.Object startRowKey,
int rowsToCheck)
areRowsLocallyAvailable in interface LocalRowKeyIndexstartRowKey - starting row key to checkrowsToCheck - number of rows to checkfalsepublic boolean areRowsLocallyAvailable(int rowsToCheck)
areRowsLocallyAvailable(startIndex, rowsToCheck)areRowsLocallyAvailable in interface LocalRowKeyIndexrowsToCheck - number of rows to checkfalseareRowsLocallyAvailable(startIndex, rowsToCheck)public boolean isRowLocallyAvailable(int rowIndex)
isRowLocallyAvailable in interface LocalRowKeyIndexrowIndex - row index to checkfalsepublic boolean isRowLocallyAvailable(java.lang.Object rowKey)
isRowLocallyAvailable in interface LocalRowKeyIndexrowKey - row key to checkfalsepublic int getEstimatedRowCount()
getEstimatedRowCount in interface LocalRowKeyIndexDataModel.getRowCount()public LocalRowKeyIndex.Confidence getEstimatedRowCountConfidence()
getEstimatedRowCount() is EXACT, or an ESTIMATE.getEstimatedRowCountConfidence in interface LocalRowKeyIndexDataModel.getRowCount()public void clearCachedRow(int index)
clearCachedRow in interface LocalRowKeyIndexindex - row index for the row to remove from cacheclearCachedRows(int, int)public void clearCachedRow(java.lang.Object rowKey)
clearCachedRow in interface LocalRowKeyIndexrowKey - row key for the row to remove from cacheclearCachedRows(Object, int)
public void clearCachedRows(int startingIndex,
int rowsToClear)
clearCachedRows in interface LocalRowKeyIndexstartingIndex - starting row index to clear the local cache fromrowsToClear - number of rows to clearclearLocalCache()
public void clearCachedRows(java.lang.Object startingRowKey,
int rowsToClear)
clearCachedRows in interface LocalRowKeyIndexstartingRowKey - starting row key to clear the local cache fromrowsToClear - number of rows to clearclearLocalCache()public void clearLocalCache()
clearLocalCache in interface LocalRowKeyIndexpublic LocalRowKeyIndex.LocalCachingStrategy getCachingStrategy()
getCachingStrategy in interface LocalRowKeyIndexLocalRowKeyIndex.LocalCachingStrategypublic void ensureRowsAvailable(int rowCount)
rowCount - the number of rows the model should hold.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.