|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.faces.model.DataModel com.sun.jsfcl.data.RowSetDataModel
Runtime implementation of javax.faces.model.DataModel
that caches retrieved database data in memory (in a session scope
attribute of type DataCache
), even when the underlying
rowset is closed.
Constructor Summary | |
RowSetDataModel()
Create a new RowSetDataModel instance not connected to
any underlying RowSet . |
|
RowSetDataModel(javax.sql.RowSet rowSet)
Create a new RowSetDataModel instance wrapping the
specified RowSet . |
Method Summary | |
void |
clear()
Clear any cached row-specific data. |
void |
commit()
Push any deleted or updated cached rows to the specified table, then call commit() on the JDBC Connection
underlying our current RowSet , as well as our associated
DataCache . |
void |
execute()
Clear any cached data, then re-execute the query for the rowset we are connected to. |
DataCache |
getDataCache()
Return the DataCache containing our cached row and
column data, creating one if necessary. |
java.lang.String |
getDataCacheKey()
Return the session attribute key under which our DataCache
instance will be stored. |
int |
getRowCount()
Return -1 to indicate that the number of rows available is unknown. |
java.lang.Object |
getRowData()
Return a Map representing the column values for
the row specified by the current rowIndex . |
int |
getRowIndex()
Return the zero-relative index of the currently positioned row, or -1 if we are not positioned on a row. |
javax.sql.RowSet |
getRowSet()
Return the RowSet we are connected with,
if any; otherwise, return null . |
java.lang.String |
getSchemaName()
Return the name of the database schema containing the table we will update when commit() is called. |
java.lang.String |
getTableName()
Return the name of the database table we will update when commit() is called. |
java.lang.Object |
getWrappedData()
Return the RowSet we are currently wrapping,
if any. |
boolean |
isRowAvailable()
Return true if there is a cache entry for the
current rowIndex value. |
void |
reset()
Reset any deleted or updated values in the cache, so that any cached rows no longer appear to have been modified. |
void |
rollback()
Reset any deleted or updated values in the cache (as is done by the reset() method), then call rollback()
on the JDBC Connectino underlying our current
RowSet . |
void |
setDataCacheKey(java.lang.String dataCacheKey)
Set the session attribute key under which our DataCache instance will be stored. |
void |
setObject(int index,
java.lang.Object value)
Set the designated parameter on the RowSet to which
we are connected. |
void |
setObject(int index,
java.lang.Object value,
int type)
Set the designated parameter on the RowSet to which
we are connected. |
void |
setObject(int index,
java.lang.Object value,
int type,
int scale)
Set the designated parameter on the RowSet to which
we are connected. |
void |
setRowIndex(int rowIndex)
Set the zero relative index for the newly positioned row, or set to -1 for no currently selected row. |
void |
setRowSet(javax.sql.RowSet rowSet)
Set the RowSet we are connected with,
or pass null to disconnect. |
void |
setSchemaName(java.lang.String schemaName)
Set the name of the database schema containing the table we will update when commit() is called. |
void |
setTableName(java.lang.String tableName)
Set the name of the database table we will update when commit() is called. |
void |
setWrappedData(java.lang.Object rowSet)
Set the RowSet wrapped by this
RowSetDataModel , or null to disconnect
from the previously connected RowSet . |
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 |
Constructor Detail |
public RowSetDataModel()
Create a new RowSetDataModel
instance not connected to
any underlying RowSet
.
public RowSetDataModel(javax.sql.RowSet rowSet)
Create a new RowSetDataModel
instance wrapping the
specified RowSet
.
rowSet
- RowSet
to be mappedMethod Detail |
public DataCache getDataCache()
Return the DataCache
containing our cached row and
column data, creating one if necessary.
public java.lang.String getDataCacheKey()
Return the session attribute key under which our DataCache
instance will be stored.
public void setDataCacheKey(java.lang.String dataCacheKey)
Set the session attribute key under which our
DataCache
instance will be stored.
dataCacheKey
- The new keypublic javax.sql.RowSet getRowSet()
Return the RowSet
we are connected with,
if any; otherwise, return null
. This is a
type=safe alias for getWrappedData()
.
public void setRowSet(javax.sql.RowSet rowSet)
Set the RowSet
we are connected with,
or pass null
to disconnect. This is a
type-safe alias for setWrappedData()
.
rowSet
- The RowSet
we are connected to,
or null
to disconnectpublic java.lang.String getSchemaName()
Return the name of the database schema containing the table
we will update when commit()
is called.
public void setSchemaName(java.lang.String schemaName)
Set the name of the database schema containing the table
we will update when commit()
is called.
schemaName
- The schema name to be updatedpublic java.lang.String getTableName()
Return the name of the database table we will update when
commit()
is called.
public void setTableName(java.lang.String tableName)
Set the name of the database table we will update when
commit()
is called.
tableName
- The table name to be updatedpublic void clear()
Clear any cached row-specific data. This method may be called by
application logic when it is known that the next page to be processed
will not involve the RowSet
we are connected to, or
when the application wants to refresh the cached data to reflect
any changes on the underlying database contents.
NOTE - Calling execute()
on this
RowSetDataModel
will implicitly call clear()
for you.
public void commit() throws java.sql.SQLException
Push any deleted or updated cached rows to the specified table,
then call commit()
on the JDBC Connection
underlying our current RowSet
, as well as our associated
DataCache
. If any SQLException
occurs, call
rollback()
on the Connection()
and
reset()
on the DataCache
.
java.lang.IllegalArgumentException
- if the tableName
property has not yet been set
java.lang.IllegalStateException
- if this method is called when
not connected to an underlying rowset
java.sql.SQLException
- if an error occurs while committingpublic void execute() throws java.sql.SQLException
Clear any cached data, then re-execute the query for the rowset we are connected to. WARNING - this method should ONLY be called when you have changed the query parameters for your query, or your application has performed other database transaction(s) on a different page that should be reflected in the query results.
java.lang.IllegalStateException
- if this method is called when
not connected to an underlying rowset
java.sql.SQLException
- if an error occurs executing the rowsetpublic void reset()
Reset any deleted or updated values in the cache, so that any cached rows no longer appear to have been modified. This method has no effect on the connected rowset (if any).
public void rollback() throws java.sql.SQLException
Reset any deleted or updated values in the cache (as is done by
the reset()
method), then call rollback()
on the JDBC Connectino
underlying our current
RowSet
.
java.lang.IllegalStateException
- if this method is called when
not connected to an underlying rowset
java.sql.SQLException
- if an error occurs while committingpublic void setObject(int index, java.lang.Object value) throws java.sql.SQLException
Set the designated parameter on the RowSet
to which
we are connected. This parameter will have no effect on any currently
selected rows; it takes effect the next time you call
execute().
index
- One-relative parameter indexvalue
- Value to be set
java.lang.IllegalStateException
- if this method is called when
not connected to an underlying rowset
java.sql.SQLException
- if an error occurs setting the parameter valuepublic void setObject(int index, java.lang.Object value, int type) throws java.sql.SQLException
Set the designated parameter on the RowSet
to which
we are connected. This parameter will have no effect on any currently
selected rows; it takes effect the next time you call
execute().
index
- One-relative parameter indexvalue
- Value to be settype
- Destination SQL type (as defined in java.sql.Types
)
java.lang.IllegalStateException
- if this method is called when
not connected to an underlying rowset
java.sql.SQLException
- if an error occurs setting the parameter valuepublic void setObject(int index, java.lang.Object value, int type, int scale) throws java.sql.SQLException
Set the designated parameter on the RowSet
to which
we are connected. This parameter will have no effect on any currently
selected rows; it takes effect the next time you call
execute().
index
- One-relative parameter indexvalue
- Value to be settype
- Destination SQL type (as defined in java.sql.Types
)scale
- For java.sql.Types.DECIMAL
or
java.sql.Types.NUMERIC
types, the number of digits
after the decimal point (ignored for all other types)
java.lang.IllegalStateException
- if this method is called when
not connected to an underlying rowset
java.sql.SQLException
- if an error occurs setting the parameter valuepublic int getRowCount()
Return -1 to indicate that the number of rows available is unknown.
public java.lang.Object getRowData()
Return a Map
representing the column values for
the row specified by the current rowIndex
. The
returned Map supports case-insensitive matching on column names,
and records any updates to the column values for later transfer
to the database when commit()
is called. It does
not allow column names (and corresponding values) to be added
or removed.
java.lang.IllegalArgumentException
- if there is no cached
data for the current rowIndex
public int getRowIndex()
Return the zero-relative index of the currently positioned row, or -1 if we are not positioned on a row.
public java.lang.Object getWrappedData()
Return the RowSet
we are currently wrapping,
if any.
public boolean isRowAvailable()
Return true
if there is a cache entry for the
current rowIndex
value.
public void setRowIndex(int rowIndex)
Set the zero relative index for the newly positioned row, or
set to -1 for no currently selected row. If there is no current
cache entry for this row, but we are currently connected, position
the underlying RowSet
to the corresponding one-relative
row number, and create a new cache entry. In addition, fire a
DataModelEvent
if needed, per the Javadocs for
this method on javax.faces.model.DataModel
.
rowIndex
- The row index, or -1 for no selected row
javax.faces.FacesException
- if an error occurs setting the row index
java.lang.IllegalArgumentException
- if rowIndex is less than -1public void setWrappedData(java.lang.Object rowSet)
Set the RowSet
wrapped by this
RowSetDataModel
, or null
to disconnect
from the previously connected RowSet
.
rowSet
- RowSet
to be wrapped, or null
to disconnect
java.lang.ClassCastException
- if this object is not of the
correct type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |