Interface ClientConnector
- All Known Subinterfaces:
Extension
- All Known Implementing Classes:
AbsoluteLayout,AbstractClientConnector,AbstractComponent,AbstractComponentContainer,AbstractLayout,AbstractOrderedLayout,AbstractSingleComponentContainer,FormLayout,GridLayout,HorizontalLayout,Label,Panel,VerticalLayout
Interface implemented by all legacy connectors that are capable of communicating with the client side.
- Author:
- Vaadin Ltd
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classEvent fired before a connector is attached from the application.static interfaceInterface for listeningconnector attach events.static classEvent fired before a connector is detached from the application.static interfaceInterface for listeningconnector attach events. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationAdd a listener for legacy connector attach events.com.vaadin.flow.shared.RegistrationAdd a listener for connector detach events.voidattach()Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).voidbeforeClientResponse(boolean initial) Called before the response is written to client side.voiddetach()Notifies the connector that it is detached from its VaadinSession.booleanChecks if the connector is attached to a VaadinSession.booleanChecks if the communicator is enabled.voidMarks that this classic component's state might have changed.voidCauses this classic component and all child components below it to be marked as dirty.
-
Method Details
-
beforeClientResponse
void beforeClientResponse(boolean initial) Called before the response is written to client side. Gives the legacy connector an opportunity to set computed/dynamic state values.This is implemented for the legacy components to keep consistent behavior and e.g. legaze size calculations working.
NOTE: the parameter
initialisfalsewhen the component is attached again to a newUIwhenPreserveOnRefreshis used.- Parameters:
initial-trueif the client-side connector will be created and initialized after this method has been invoked.falseif there is already an initialized client-side connector.
-
markAsDirty
void markAsDirty()Marks that this classic component's state might have changed. When the framework is about to send new data to the client-side, it will runbeforeClientResponse(boolean)for all legacy components that are marked as dirty. -
markAsDirtyRecursive
void markAsDirtyRecursive()Causes this classic component and all child components 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.
This will go through the whole component subtree, including any non-legacy components.
- See Also:
-
addLegacyAttachListener
com.vaadin.flow.shared.Registration addLegacyAttachListener(ClientConnector.AttachListener listener) Add a listener for legacy connector attach events. This could be migrated toAttachNotifier.addAttachListener(ComponentEventListener).- Parameters:
listener- the listener to add- Returns:
- Registration for unregistering the listener
-
addLegacyDetachListener
com.vaadin.flow.shared.Registration addLegacyDetachListener(ClientConnector.DetachListener listener) Add a listener for connector detach events. This could be migrated toDetachNotifier.addDetachListener(ComponentEventListener)- Parameters:
listener- the listener to add- Returns:
- Registration for unregistering the listener
-
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
ComponentUtil.onComponentAttach(Component, boolean)} if the parent is itself already attached to the session. If not, it's called when the parent 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. -
isAttached
boolean isAttached()Checks if the connector is attached to a VaadinSession.- Returns:
- true if the connector is attached to a session, false otherwise
-
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
-