org.apache.myfaces.component.html.ext
Class _SerializableDataModel

java.lang.Object
  extended by javax.faces.model.DataModel
      extended by org.apache.myfaces.component.html.ext._SerializableDataModel
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
_SerializableArrayDataModel, _SerializableListDataModel, _SerializableResultDataModel, _SerializableResultSetDataModel, _SerializableScalarDataModel

 class _SerializableDataModel
extends javax.faces.model.DataModel
implements java.io.Serializable

Provide a serializable equivalent of the standard DataModel classes.

The standard JSF UIData components accept a DataModel as the "value" for the ordered sequence of objects to be rendered in the table. Various types (List, array, ResultSet) are also accepted and automatically wrapped in one of the standard DataModel classes.

The standard DataModel classes are not Serializable by default, because there is no state in the class which needs to be preserved between render and postback. And the standard UIData components don't serialize the data model object, just the EL expression for the "value" attribute; the data itself is refetched when needed by re-evaluating the EL expression.

However there can be good reasons to serialize the list of data that is wrapped by the DataModel along with the UIData component. For these cases, the tomahawk t:dataTable component offers a "preserveDataModel" flag that will automatically serialize the data model along with the HtmlDataTable component; it does this by invoking the "value" binding of the t:dataTable then creating an instance of this class or one of its subclasses instead of the standard JSF DataModels.

This class performs two roles. It is the base implementation for specialised classes that wrap various datatypes that can be returned from the table's "value" binding. It also implements the case where the value object returned is of type DataModel.

When the UIData's "value" binding returns a DataModel instance, this class extracts each rowData object from the wrapped data of the original DataModel and adds these objects to an instance of this class which is Serializable. Of course the rowdata objects must be serializable for this to work. As a side-effect, however, the original DataModel object will be discarded, and replaced by an instance of this class. This means that any special optimisations or behaviour of the concrete DataModel subclass will be lost.

Version:
$Revision: 472630 $ $Date: 2006-11-08 21:40:03 +0100 (Wed, 08 Nov 2006) $
Author:
Manfred Geiler (latest modification by $Author: grantsmith $)

Field Summary
protected  int _first
           
protected  java.util.List _list
           
protected  int _rowCount
           
protected  int _rows
           
 
Constructor Summary
protected _SerializableDataModel()
           
  _SerializableDataModel(int first, int rows, javax.faces.model.DataModel dataModel)
           
 
Method Summary
 int getFirst()
           
 int getRowCount()
           
 java.lang.Object getRowData()
           
 int getRowIndex()
           
 int getRows()
           
 java.lang.Object getWrappedData()
           
 boolean isRowAvailable()
           
 void setFirst(int first)
           
 void setRowIndex(int rowIndex)
           
 void setRows(int rows)
           
 void setWrappedData(java.lang.Object obj)
           
 
Methods inherited from class javax.faces.model.DataModel
addDataModelListener, getDataModelListeners, removeDataModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_first

protected int _first

_rows

protected int _rows

_rowCount

protected int _rowCount

_list

protected java.util.List _list
Constructor Detail

_SerializableDataModel

public _SerializableDataModel(int first,
                              int rows,
                              javax.faces.model.DataModel dataModel)

_SerializableDataModel

protected _SerializableDataModel()
Method Detail

getFirst

public int getFirst()

setFirst

public void setFirst(int first)

getRows

public int getRows()

setRows

public void setRows(int rows)

isRowAvailable

public boolean isRowAvailable()
Specified by:
isRowAvailable in class javax.faces.model.DataModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in class javax.faces.model.DataModel

getRowData

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

getRowIndex

public int getRowIndex()
Specified by:
getRowIndex in class javax.faces.model.DataModel

setRowIndex

public void setRowIndex(int rowIndex)
Specified by:
setRowIndex in class javax.faces.model.DataModel

getWrappedData

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

setWrappedData

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


Copyright 2008 The Apache Software Foundation. All Rights Reserved.