org.richfaces.model
Class ScrollableTableDataModel<T>

java.lang.Object
  extended by javax.faces.model.DataModel
      extended by org.ajax4jsf.model.ExtendedDataModel
          extended by org.richfaces.model.ScrollableTableDataModel<T>

public abstract class ScrollableTableDataModel<T>
extends ExtendedDataModel

Base class for data models Subclasses must implement loadData(int, int, SortOrder) For certain features (like selection and sorting) to work correctly together, both getId(Object) and getObjectById(Object) methods need to be overriden

Author:
Maksim Kaszynski

Nested Class Summary
static class ScrollableTableDataModel.SimpleRowKey
          Simple implementation - index-based row key
 
Field Summary
protected  SortOrder lastSortOrder
           
 
Constructor Summary
ScrollableTableDataModel()
           
 
Method Summary
 java.lang.Object getId(T o)
          Implementations may override it to provide domain-specific searches Id should be serializable Default implementation returns null anyway If you override this method, you need to override getObjectById(Object) as well
 T getObjectById(java.lang.Object id)
          This method is the reverse of getId(Object) If you override this method, you need to override getId(Object) as well
 java.lang.Object getRowData()
           
 int getRowIndex()
          Row indexes navigation is no longer supported
 java.lang.Object getRowKey()
           
 boolean isRowAvailable()
          Quite simple implementation - data will be cached, so the call will be cheap
abstract  java.util.List<T> loadData(int startRow, int endRow, SortOrder sortOrder)
          Load range of data items from the source.
 void setRowIndex(int index)
          Row indexes navigation is no longer supported
 void setRowKey(java.lang.Object key)
          Instead of simple int for current state selection, this model can use any object for select current data.
 void walk(javax.faces.context.FacesContext context, DataVisitor visitor, Range range, java.lang.Object argument)
          Load data range, and iterate over it
 
Methods inherited from class org.ajax4jsf.model.ExtendedDataModel
getSerializableModel
 
Methods inherited from class javax.faces.model.DataModel
addDataModelListener, getDataModelListeners, getRowCount, getWrappedData, removeDataModelListener, setWrappedData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastSortOrder

protected SortOrder lastSortOrder
Constructor Detail

ScrollableTableDataModel

public ScrollableTableDataModel()
Method Detail

loadData

public abstract java.util.List<T> loadData(int startRow,
                                           int endRow,
                                           SortOrder sortOrder)
Load range of data items from the source. Starting from startRow, and up to but excluding endRow

Parameters:
startRow -
endRow -
sortOrder -
Returns:
list of ordered data

walk

public void walk(javax.faces.context.FacesContext context,
                 DataVisitor visitor,
                 Range range,
                 java.lang.Object argument)
          throws java.io.IOException
Load data range, and iterate over it

Specified by:
walk in class ExtendedDataModel
Parameters:
context - current JSF context.
visitor - instance of DataVisitor, for process each row.
range - Implementation-specific range of data keys.
argument - Implementation-specific argument
Throws:
java.io.IOException

getObjectById

public T getObjectById(java.lang.Object id)
This method is the reverse of getId(Object) If you override this method, you need to override getId(Object) as well

Parameters:
id -
Returns:

getId

public java.lang.Object getId(T o)
Implementations may override it to provide domain-specific searches Id should be serializable Default implementation returns null anyway If you override this method, you need to override getObjectById(Object) as well

Parameters:
o -
Returns:

getRowData

public java.lang.Object getRowData()
Specified by:
getRowData in class javax.faces.model.DataModel

getRowIndex

public int getRowIndex()
Row indexes navigation is no longer supported

Specified by:
getRowIndex in class javax.faces.model.DataModel

isRowAvailable

public boolean isRowAvailable()
Quite simple implementation - data will be cached, so the call will be cheap

Specified by:
isRowAvailable in class javax.faces.model.DataModel

setRowIndex

public void setRowIndex(int index)
Row indexes navigation is no longer supported

Specified by:
setRowIndex in class javax.faces.model.DataModel

getRowKey

public java.lang.Object getRowKey()
Specified by:
getRowKey in class ExtendedDataModel
Returns:
key for selected data or null

setRowKey

public void setRowKey(java.lang.Object key)
Description copied from class: ExtendedDataModel

Instead of simple int for current state selection, this model can use any object for select current data. Implementation depend on model, with any restrictions :

  1. key must be Serializable.
  2. Object.toString() method must return representation compatible with UIComponent.getClientId(javax.faces.context.FacesContext), as far as this string will be appended to clientId of iterator component.

Specified by:
setRowKey in class ExtendedDataModel
Parameters:
key - key for select current data, or null for clear selection.


Copyright © 2010. All Rights Reserved.