|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.widgetideas.table.client.TableModel<R>
com.google.gwt.widgetideas.table.client.CachedTableModel<R>
R
- the data type of the row valuespublic class CachedTableModel<R>
A TableModel
that wraps another TableModel
and adds its own
cache so subsequent requests for the same data will not require another
TableModel
request.
The CachedTableModel supports caching rows of data before they are needed, allowing listeners to request data much more quickly. When another class requests data, the CachedTableModel will feed data from its cache if available, and then it will request unavailable data from your specific implementation.
The pre cache and post cache refers to the number of rows to request in addition to the actual request. Pre cache refers to rows before the request, and post cache refers to rows after the request. For example, in applications where you expect the user to move forward quickly, you would want a large post cache.
The size of your cache depends on the implementation and usage of your view
component. If you are using a view that supports paging, such as the
PagingScrollTable
, you should set your cache to a multiple of the
page size so the user can go to the next and previous pages quickly.
The cache is cleared every time the sort order changes. However, if you disallow column sorting or expect that the user will not sort the columns repeatedly, the cache will still improve paging performance.
Nested Class Summary | |
---|---|
class |
CachedTableModel.CacheCallback
A callback that retrieves data from the cache. |
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.TableModel |
---|
TableModel.Callback<R>, TableModel.ColumnSortInfo, TableModel.ColumnSortList, TableModel.Request, TableModel.Response<R>, TableModel.SerializableResponse<R extends java.io.Serializable> |
Field Summary |
---|
Fields inherited from class com.google.gwt.widgetideas.table.client.TableModel |
---|
ALL_ROWS, UNKNOWN_ROW_COUNT |
Constructor Summary | |
---|---|
CachedTableModel(TableModel<R> tableModel)
Constructor. |
Method Summary | |
---|---|
void |
clearCache()
Clear all data from the cache. |
int |
getPostCachedRowCount()
|
int |
getPreCachedRowCount()
|
protected boolean |
onRowInserted(int beforeRow)
Event fired when a row is inserted. |
protected boolean |
onRowRemoved(int row)
Event fired when a row is removed. |
protected boolean |
onSetData(int row,
int cell,
java.lang.Object data)
Event fired when the local data changes. |
void |
requestRows(TableModel.Request request,
TableModel.Callback<R> callback)
Generate a TableModel.Response based on a specific TableModel.Request . |
void |
setPostCachedRowCount(int postCacheRows)
Set the number of rows to cache after the visible data area. |
void |
setPreCachedRowCount(int preCacheRows)
Set the number of rows to cache before the visible data area. |
Methods inherited from class com.google.gwt.widgetideas.table.client.TableModel |
---|
addTableModelListener, getRowCount, insertRow, removeRow, removeTableModelListener, setData, setRowCount |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachedTableModel(TableModel<R> tableModel)
tableModel
- the underlying TableModel
Method Detail |
---|
public void clearCache()
public int getPostCachedRowCount()
public int getPreCachedRowCount()
public void requestRows(TableModel.Request request, TableModel.Callback<R> callback)
TableModel
TableModel.Response
based on a specific TableModel.Request
. The
response is passed into the TableModel.Callback
.
requestRows
in class TableModel<R>
request
- the TableModel.Request
for row datacallback
- the TableModel.Callback
to use for the TableModel.Response
public void setPostCachedRowCount(int postCacheRows)
postCacheRows
- the number of rows to post cachepublic void setPreCachedRowCount(int preCacheRows)
preCacheRows
- the number of rows to pre cacheprotected boolean onRowInserted(int beforeRow)
TableModel
onRowInserted
in class TableModel<R>
beforeRow
- the row index of the new row
protected boolean onRowRemoved(int row)
TableModel
onRowRemoved
in class TableModel<R>
row
- the row index of the removed row
protected boolean onSetData(int row, int cell, java.lang.Object data)
TableModel
onSetData
in class TableModel<R>
row
- the row indexcell
- the cell indexdata
- the new contents of the cell
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |