T - the bean typepublic class DataCommunicator<T> extends AbstractExtension
DataGenerators to write
JsonObjects representing each data object to be sent to the
client-side.| Modifier and Type | Class and Description |
|---|---|
protected class |
DataCommunicator.ActiveDataHandler
A class for handling currently active data and dropping data that is no
longer needed.
|
protected class |
DataCommunicator.SimpleDataRequestRpc
Simple implementation of collection data provider communication.
|
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener| Constructor and Description |
|---|
DataCommunicator() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDataGenerator(DataGenerator<T> generator)
Adds a data generator to this data communicator.
|
void |
attach()
Notifies the connector that it is connected to a VaadinSession (and
therefore also to a UI).
|
void |
beforeClientResponse(boolean initial)
Initially and in the case of a reset all data should be pushed to the
client.
|
protected DataKeyMapper<T> |
createKeyMapper()
Creates a
DataKeyMapper to use with this DataCommunicator. |
protected DataRequestRpc |
createRpc()
Creates a
DataRequestRpc used with this DataCommunicator. |
void |
detach()
Notifies the connector that it is detached from its VaadinSession.
|
protected elemental.json.JsonObject |
getDataObject(T data)
Creates the JsonObject for given data object.
|
DataProvider<T,?> |
getDataProvider()
Gets the current data provider from this DataCommunicator.
|
DataKeyMapper<T> |
getKeyMapper()
Gets the
DataKeyMapper used by this DataCommunicator. |
int |
getMinPushSize()
Get minimum size of data which will be sent to the client when data
source is set.
|
protected DataCommunicatorState |
getState()
Returns the shared state for this connector.
|
protected DataCommunicatorState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
protected void |
pushData(int firstIndex,
Stream<T> data)
Sends given collection of data objects to the client-side.
|
void |
refresh(T data)
Informs the DataProvider that a data object has been updated.
|
void |
removeDataGenerator(DataGenerator<T> generator)
Removes a data generator from this data communicator.
|
void |
reset()
Informs the DataProvider that the collection has changed.
|
void |
setBackEndSorting(List<QuerySortOrder> sortOrder)
Sets the
QuerySortOrders to use with backend sorting. |
<F> SerializableConsumer<F> |
setDataProvider(DataProvider<T,F> dataProvider,
F initialFilter)
Sets the current data provider for this DataCommunicator.
|
void |
setInMemorySorting(Comparator<T> comparator)
Sets the
Comparator to use with in-memory sorting. |
void |
setMinPushSize(int size)
Set minimum size of data which will be sent to the client when data
source is set.
|
extend, getParent, getSupportedParentType, remove, setParentaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaddAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdpublic void attach()
ClientConnector
The caller of this method is #setParent(ClientConnector) if the
parent is itself already attached to the session. If not, the parent will
call the ClientConnector.attach() for all its children when it is attached to
the session. This method is always called before the connector's data is
sent to the client-side for the first time.
The attachment logic is implemented in AbstractClientConnector.
attach in interface ClientConnectorattach in class AbstractClientConnectorpublic void detach()
AbstractClientConnector
The caller of this method is #setParent(ClientConnector) if the
parent is in the session. When the parent is detached from the session it
is its responsibility to call ClientConnector.detach() for each of its children.
The AbstractClientConnector.getSession() and AbstractClientConnector.getUI() methods might return
null after this method is called.
detach in interface ClientConnectordetach in class AbstractClientConnectorpublic void beforeClientResponse(boolean initial)
beforeClientResponse in interface ClientConnectorbeforeClientResponse in class AbstractClientConnectorinitial - true if the client-side connector will be created
and initialized after this method has been invoked.
false if there is already an initialized
client-side connector.public void addDataGenerator(DataGenerator<T> generator)
generator - the data generator to add, not nullpublic void removeDataGenerator(DataGenerator<T> generator)
generator - the data generator to remove, not nullpublic DataKeyMapper<T> getKeyMapper()
DataKeyMapper used by this DataCommunicator. Key
mapper can be used to map keys sent to the client-side back to their
respective data objects.protected void pushData(int firstIndex,
Stream<T> data)
firstIndex - first index of pushed datadata - data objects to send as an iterableprotected elemental.json.JsonObject getDataObject(T data)
data - data object to be made into a json objectpublic void reset()
public void refresh(T data)
data - updated data objectpublic void setInMemorySorting(Comparator<T> comparator)
Comparator to use with in-memory sorting.comparator - comparator used to sort datapublic void setBackEndSorting(List<QuerySortOrder> sortOrder)
QuerySortOrders to use with backend sorting.sortOrder - list of sort order information to pass to a queryprotected DataKeyMapper<T> createKeyMapper()
DataKeyMapper to use with this DataCommunicator.
This method is called from the constructor.
protected DataRequestRpc createRpc()
DataRequestRpc used with this DataCommunicator.
This method is called from the constructor.
public DataProvider<T,?> getDataProvider()
public <F> SerializableConsumer<F> setDataProvider(DataProvider<T,F> dataProvider, F initialFilter)
The returned consumer can be used to set some other filter value that should be included in queries sent to the data provider. It is only valid until another data provider is set.
F - the filter typedataProvider - the data provider to set, not nullinitialFilter - the initial filter value to use, or null to not
use any initial filter valuepublic void setMinPushSize(int size)
Server doesn't send all data from data source to the client. It sends
some initial chunk of data (whose size is determined as minimum between
size parameter of this method and data size). Client decides
whether it is able to show more data and request server to send more data
(next chunk).
When component is disabled then client cannot communicate to the server side (by design, because of security reasons). It means that client will get only initial chunk of data whose size is set here.
size - the size of initial data to send to the clientpublic int getMinPushSize()
setMinPushSize(int)protected DataCommunicatorState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractClientConnectormarkAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()protected DataCommunicatorState getState()
AbstractClientConnector
As a side effect, marks the connector dirty so any changes done to the
state will be sent to the client. Use getState(false) to avoid
marking the connector as dirty.
getState in class AbstractClientConnectorCopyright © 2017 Vaadin Ltd. All rights reserved.