Interface ClientConnector
-
- All Superinterfaces:
Connector
,Serializable
- All Known Subinterfaces:
Component
,Component.Focusable
,ComponentContainer
,DragSource
,DropTarget
,Extension
,Field<T>
,Grid.SelectionModel
,Grid.SelectionModel.HasUserSelectionAllowed
,Grid.SelectionModel.Multi
,Grid.SelectionModel.None
,Grid.SelectionModel.Single
,HasChildMeasurementHint
,HasComponents
,Layout
,LegacyComponent
,Renderer<T>
,SelectiveRenderer
,SingleComponentContainer
- All Known Implementing Classes:
AbsoluteLayout
,AbstractClientConnector
,AbstractColorPicker
,AbstractComponent
,AbstractComponentContainer
,AbstractEmbedded
,AbstractExtension
,AbstractField
,AbstractFocusable
,AbstractJavaScriptComponent
,AbstractJavaScriptExtension
,AbstractJavaScriptRenderer
,AbstractLayout
,AbstractMedia
,AbstractOrderedLayout
,AbstractSelect
,AbstractSingleComponentContainer
,AbstractSplitPanel
,AbstractTextField
,Accordion
,Audio
,BrowserFrame
,BrowserWindowOpener
,Button
,ButtonRenderer
,Calendar
,CheckBox
,ClickableRenderer
,ColorPicker
,ColorPickerArea
,ColorPickerGradient
,ColorPickerGrid
,ColorPickerHistory
,ColorPickerPopup
,ColorPickerPreview
,ColorPickerSelect
,ComboBox
,CssLayout
,CustomComponent
,CustomField
,CustomLayout
,DateField
,DateRenderer
,DragAndDropService
,DragAndDropWrapper
,Embedded
,FileDownloader
,Flash
,Form
,FormLayout
,Grid
,Grid.AbstractGridExtension
,Grid.AbstractRenderer
,Grid.AbstractSelectionModel
,Grid.DetailComponentManager
,Grid.MultiSelectionModel
,Grid.NoSelectionModel
,Grid.SingleSelectionModel
,GridLayout
,HorizontalLayout
,HorizontalSplitPanel
,HtmlRenderer
,Image
,ImageRenderer
,InlineDateField
,JavaScript
,Label
,LegacyWindow
,Link
,ListSelect
,LoginForm
,MenuBar
,NativeButton
,NativeSelect
,Navigator.EmptyView
,NumberRenderer
,OptionGroup
,Panel
,PasswordField
,PopupDateField
,PopupView
,ProgressBar
,ProgressBarRenderer
,ProgressIndicator
,Responsive
,RichTextArea
,RpcDataProviderExtension
,Select
,Slider
,Table
,TabSheet
,TextArea
,TextField
,TextRenderer
,Tree
,TreeTable
,TwinColSelect
,UI
,Upload
,VerticalLayout
,VerticalSplitPanel
,Video
,Window
public interface ClientConnector extends Connector
Interface implemented by all connectors that are capable of communicating with the client side- Since:
- 7.0.0
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ClientConnector.AttachEvent
Event fired after a connector is attached to the application.static interface
ClientConnector.AttachListener
Interface for listeningconnector 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 listeningconnector detach events
.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method 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, ornull
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 connectorUI
getUI()
Returns the UI this connector is attached toboolean
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, usemarkAsDirty()
insteadvoid
requestRepaintAll()
Deprecated.As of 7.0, usemarkAsDirtyRecursive()
insteadList<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.-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
-
-
-
Method Detail
-
addAttachListener
void addAttachListener(ClientConnector.AttachListener listener)
-
removeAttachListener
void removeAttachListener(ClientConnector.AttachListener listener)
-
addDetachListener
void addDetachListener(ClientConnector.DetachListener listener)
-
removeDetachListener
void removeDetachListener(ClientConnector.DetachListener listener)
-
retrievePendingRpcCalls
List<ClientMethodInvocation> retrievePendingRpcCalls()
Returns the list of pending server to client RPC calls and clears the list.- Returns:
- an unmodifiable ordered list of pending server to client method calls (not null)
-
isConnectorEnabled
boolean isConnectorEnabled()
Checks if the communicator is enabled. An enabled communicator is allowed to receive messages from its counter-part.- Returns:
- true if the connector can receive messages, false otherwise
-
getStateType
Class<? extends SharedState> getStateType()
Returns the type of the shared state for this connector- Returns:
- The type of the state. Must never return null.
-
getParent
ClientConnector getParent()
Description copied from interface:Connector
Gets the parent connector of this connector, ornull
if the connector is not attached to any parent.
-
requestRepaint
@Deprecated void requestRepaint()
Deprecated.As of 7.0, usemarkAsDirty()
instead
-
markAsDirty
void markAsDirty()
Marks that this connector's state might have changed. When the framework is about to send new data to the client-side, it will runbeforeClientResponse(boolean)
followed byencodeState()
for all connectors that are marked as dirty and send any updated state info to the client.- Since:
- 7.0.0
-
requestRepaintAll
@Deprecated void requestRepaintAll()
Deprecated.As of 7.0, usemarkAsDirtyRecursive()
instead
-
markAsDirtyRecursive
void markAsDirtyRecursive()
Causes this connector and all connectors below it to be marked as dirty.This should only be used in special cases, e.g when the state of a descendant depends on the state of an ancestor.
- Since:
- 7.0.0
- See Also:
markAsDirty()
-
isAttached
boolean isAttached()
Checks if the connector is attached to a VaadinSession.- Returns:
- true if the connector is attached to a session, false otherwise
- Since:
- 7.1
-
attach
void attach()
Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).The caller of this method is
#setParent(ClientConnector)
if the parent is itself already attached to the session. If not, the parent will call theattach()
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
.
-
detach
void detach()
Notifies the connector that it is detached from its VaadinSession.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 calldetach()
for each of its children.
-
getExtensions
Collection<Extension> getExtensions()
Get a read-only collection of all extensions attached to this connector.- Returns:
- a collection of extensions
-
removeExtension
void removeExtension(Extension extension)
Remove an extension from this connector.- Parameters:
extension
- the extension to remove.
-
getUI
UI getUI()
Returns the UI this connector is attached to- Returns:
- The UI this connector is attached to or null if it is not attached to any UI
-
beforeClientResponse
void beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.- Parameters:
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.- Since:
- 7.0
-
encodeState
JsonObject encodeState()
Called by the framework to encode the state to a JSONObject. This is typically done by calling the static methodLegacyCommunicationManager.encodeState(ClientConnector, SharedState)
.- Returns:
- a JSON object with the encoded connector state
-
handleConnectorRequest
boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException
Handle a request directed to this connector. This can be used by connectors to dynamically generate a response and it is also used internally when servingConnectorResource
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.
- Parameters:
request
- the request that should be handledresponse
- the response object to which the response should be writtenpath
- the requested relative path- Returns:
true
if the request has been handled,false
if no response has been written.- Throws:
IOException
- if there is a problem generating a response.
-
getRpcManager
ServerRpcManager<?> getRpcManager(String rpcInterfaceName)
Returns the RPC manager instance to use when receiving calls for an RPC interface.- Parameters:
rpcInterfaceName
- name of the interface for which the call was made- Returns:
- ServerRpcManager or null if none found for the interface
-
getErrorHandler
ErrorHandler getErrorHandler()
Gets the error handler for the connector. The error handler is dispatched whenever there is an error processing the data coming from the client to this connector.- Returns:
- The error handler or null if not set
-
setErrorHandler
void setErrorHandler(ErrorHandler errorHandler)
Sets the error handler for the connector. The error handler is dispatched whenever there is an error processing the data coming from the client for this connector.- Parameters:
errorHandler
- The error handler for this connector
-
-