Class RpcDataSourceConnector.RpcDataSource
- java.lang.Object
-
- com.vaadin.client.data.AbstractRemoteDataSource<elemental.json.JsonObject>
-
- com.vaadin.client.connectors.RpcDataSourceConnector.RpcDataSource
-
- All Implemented Interfaces:
DataSource<elemental.json.JsonObject>
- Enclosing class:
- RpcDataSourceConnector
public class RpcDataSourceConnector.RpcDataSource extends AbstractRemoteDataSource<elemental.json.JsonObject>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.client.data.AbstractRemoteDataSource
AbstractRemoteDataSource.RequestRowsCallback<T>, AbstractRemoteDataSource.RowHandleImpl
-
Nested classes/interfaces inherited from interface com.vaadin.client.data.DataSource
DataSource.RowHandle<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRpcDataSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanFetchData()Checks if it is possible to currently fetch data from the remote data source.voidensureAvailability(int firstRowIndex, int numberOfRows)Informs the data source that data for the given range is needed.DataSource.RowHandle<elemental.json.JsonObject>getHandleByKey(Object key)StringgetRowKey(elemental.json.JsonObject row)Gets a stable key for the row object.protected voidonDropFromCache(int rowIndex, elemental.json.JsonObject row)A hook that can be overridden to do something whenever a row has been dropped from the cache.protected voidrequestRows(int firstRowIndex, int numberOfRows, AbstractRemoteDataSource.RequestRowsCallback<elemental.json.JsonObject> callback)Triggers fetching rows from the remote data source.protected voidsetRowData(int firstRowIndex, List<elemental.json.JsonObject> rowData)Informs this data source that updated data has been sent from the server.protected voidunpinHandle(AbstractRemoteDataSource.RowHandleImpl handle)Unpins a previously pinned row with given handle.protected voidupdateRowData(elemental.json.JsonObject row)Updates row data based on row key.-
Methods inherited from class com.vaadin.client.data.AbstractRemoteDataSource
getCachedRange, getHandle, getRequestedAvailability, getRow, indexOf, indexOfKey, insertRowData, isPinned, isWaitingForData, onDropFromCache, pinHandle, removeRowData, resetDataAndSize, setCacheStrategy, setDataChangeHandler, size
-
-
-
-
Method Detail
-
requestRows
protected void requestRows(int firstRowIndex, int numberOfRows, AbstractRemoteDataSource.RequestRowsCallback<elemental.json.JsonObject> callback)Description copied from class:AbstractRemoteDataSourceTriggers fetching rows from the remote data source. The provided callback should be informed when the requested rows have been received.- Specified by:
requestRowsin classAbstractRemoteDataSource<elemental.json.JsonObject>- Parameters:
firstRowIndex- the index of the first row to fetchnumberOfRows- the number of rows to fetchcallback- callback to inform when the requested rows are available
-
ensureAvailability
public void ensureAvailability(int firstRowIndex, int numberOfRows)Description copied from interface:DataSourceInforms the data source that data for the given range is needed. A data source only has one active region at a time, so calling this method discards the previously set range.This method triggers lazy loading of data if necessary. The change handler registered using
DataSource.setDataChangeHandler(DataChangeHandler)is informed when new data has been loaded.After any possible lazy loading and updates are done, the change handler is informed that new data is available.
- Specified by:
ensureAvailabilityin interfaceDataSource<elemental.json.JsonObject>- Overrides:
ensureAvailabilityin classAbstractRemoteDataSource<elemental.json.JsonObject>- Parameters:
firstRowIndex- the index of the first needed rownumberOfRows- the number of needed rows
-
getRowKey
public String getRowKey(elemental.json.JsonObject row)
Description copied from class:AbstractRemoteDataSourceGets a stable key for the row object.This method is a workaround for the fact that there is no means to force proper implementations for
Object.hashCode()andObject.equals(Object)methods.Since the same row object will be created several times for the same logical data, the DataSource needs a mechanism to be able to compare two objects, and figure out whether or not they represent the same data. Even if all the fields of an entity would be changed, it still could represent the very same thing (say, a person changes all of her names.)
A very usual and simple example what this could be, is an unique ID for this object that would also be stored in a database.
- Specified by:
getRowKeyin classAbstractRemoteDataSource<elemental.json.JsonObject>- Parameters:
row- the row object for which to get the key- Returns:
- a non-null object that uniquely and consistently represents the row object
-
getHandleByKey
public DataSource.RowHandle<elemental.json.JsonObject> getHandleByKey(Object key)
-
unpinHandle
protected void unpinHandle(AbstractRemoteDataSource.RowHandleImpl handle)
Description copied from class:AbstractRemoteDataSourceUnpins a previously pinned row with given handle. This function can be overridden to do specific logic related to unpinning rows.- Overrides:
unpinHandlein classAbstractRemoteDataSource<elemental.json.JsonObject>- Parameters:
handle- row handle to unpin
-
setRowData
protected void setRowData(int firstRowIndex, List<elemental.json.JsonObject> rowData)Description copied from class:AbstractRemoteDataSourceInforms this data source that updated data has been sent from the server.- Overrides:
setRowDatain classAbstractRemoteDataSource<elemental.json.JsonObject>- Parameters:
firstRowIndex- the index of the first received rowrowData- a list of rows, starting fromfirstRowIndex
-
updateRowData
protected void updateRowData(elemental.json.JsonObject row)
Updates row data based on row key.- Parameters:
row- new row object- Since:
- 7.6
-
onDropFromCache
protected void onDropFromCache(int rowIndex, elemental.json.JsonObject row)Description copied from class:AbstractRemoteDataSourceA hook that can be overridden to do something whenever a row has been dropped from the cache. DataSource no longer has anything in the given index.- Overrides:
onDropFromCachein classAbstractRemoteDataSource<elemental.json.JsonObject>- Parameters:
rowIndex- the index of the dropped rowrow- the removed row object
-
canFetchData
protected boolean canFetchData()
Description copied from class:AbstractRemoteDataSourceChecks if it is possible to currently fetch data from the remote data source.- Overrides:
canFetchDatain classAbstractRemoteDataSource<elemental.json.JsonObject>- Returns:
trueif it is ok to try to fetch data,falseif it is known that fetching data will fail and should not be tried right now.
-
-