public interface ClientConnector extends Connector
Modifier and Type | Interface and Description |
---|---|
static class |
ClientConnector.AttachEvent
Event fired after a connector is attached to the application.
|
static interface |
ClientConnector.AttachListener
Interface for listening
connector attach events . |
static class |
ClientConnector.ConnectorErrorEvent
An error event for connector related errors.
|
static class |
ClientConnector.DetachEvent
Event fired before a connector is detached from the application.
|
static interface |
ClientConnector.DetachListener
Interface for listening
connector detach events . |
Modifier and Type | Method and Description |
---|---|
void |
addAttachListener(ClientConnector.AttachListener listener) |
void |
addDetachListener(ClientConnector.DetachListener listener) |
void |
attach()
Notifies the connector that it is connected to a VaadinSession (and
therefore also to a UI).
|
void |
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the
client.
|
void |
detach()
Notifies the connector that it is detached from its VaadinSession.
|
JsonObject |
encodeState()
Called by the framework to encode the state to a JSONObject.
|
ErrorHandler |
getErrorHandler()
Gets the error handler for the connector.
|
Collection<Extension> |
getExtensions()
Get a read-only collection of all extensions attached to this connector.
|
ClientConnector |
getParent()
Gets the parent connector of this connector, or
null if the
connector is not attached to any parent. |
ServerRpcManager<?> |
getRpcManager(String rpcInterfaceName)
Returns the RPC manager instance to use when receiving calls for an RPC
interface.
|
Class<? extends SharedState> |
getStateType()
Returns the type of the shared state for this connector
|
UI |
getUI()
Returns the UI this connector is attached to
|
boolean |
handleConnectorRequest(VaadinRequest request,
VaadinResponse response,
String path)
Handle a request directed to this connector.
|
boolean |
isAttached()
Checks if the connector is attached to a VaadinSession.
|
boolean |
isConnectorEnabled()
Checks if the communicator is enabled.
|
void |
markAsDirty()
Marks that this connector's state might have changed.
|
void |
markAsDirtyRecursive()
Causes this connector and all connectors below it to be marked as dirty.
|
void |
removeAttachListener(ClientConnector.AttachListener listener) |
void |
removeDetachListener(ClientConnector.DetachListener listener) |
void |
removeExtension(Extension extension)
Remove an extension from this connector.
|
void |
requestRepaint()
Deprecated.
As of 7.0, use
markAsDirty() instead |
void |
requestRepaintAll()
Deprecated.
As of 7.0, use
markAsDirtyRecursive() instead |
List<ClientMethodInvocation> |
retrievePendingRpcCalls()
Returns the list of pending server to client RPC calls and clears the
list.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the error handler for the connector.
|
getConnectorId
void addAttachListener(ClientConnector.AttachListener listener)
void removeAttachListener(ClientConnector.AttachListener listener)
void addDetachListener(ClientConnector.DetachListener listener)
void removeDetachListener(ClientConnector.DetachListener listener)
List<ClientMethodInvocation> retrievePendingRpcCalls()
boolean isConnectorEnabled()
Class<? extends SharedState> getStateType()
ClientConnector getParent()
Connector
null
if the
connector is not attached to any parent.@Deprecated void requestRepaint()
markAsDirty()
insteadvoid markAsDirty()
beforeClientResponse(boolean)
followed by encodeState()
for all connectors that are marked as dirty and send any updated state
info to the client.@Deprecated void requestRepaintAll()
markAsDirtyRecursive()
insteadvoid markAsDirtyRecursive()
This should only be used in special cases, e.g when the state of a descendant depends on the state of an ancestor.
markAsDirty()
boolean isAttached()
void attach()
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 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
.
void detach()
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 detach()
for each of its children.
Collection<Extension> getExtensions()
void removeExtension(Extension extension)
extension
- the extension to remove.UI getUI()
void beforeClientResponse(boolean initial)
initial
- 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.JsonObject encodeState()
LegacyCommunicationManager.encodeState(ClientConnector, SharedState)
.boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException
ConnectorResource
s.
Requests to /APP/connector/[ui id]/[connector id]/
are
routed to this method with the remaining part of the requested path
available in the path parameter.
NOTE that the session is not locked when this method is called. It is the responsibility of the connector to ensure that the session is locked while handling state or other session related data. For best performance the session should be unlocked before writing a large response to the client.
request
- the request that should be handledresponse
- the response object to which the response should be writtenpath
- the requested relative pathtrue
if the request has been handled,
false
if no response has been written.IOException
- if there is a problem generating a response.ServerRpcManager<?> getRpcManager(String rpcInterfaceName)
rpcInterfaceName
- name of the interface for which the call was madeErrorHandler getErrorHandler()
void setErrorHandler(ErrorHandler errorHandler)
errorHandler
- The error handler for this connectorCopyright © 2019 Vaadin Ltd. All rights reserved.