Class AbstractClientConnector

  • All Implemented Interfaces:
    ClientConnector, com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, java.io.Serializable
    Direct Known Subclasses:
    AbstractComponent

    public abstract class AbstractClientConnector
    extends com.vaadin.flow.component.Component
    implements ClientConnector
    An abstract base class for legacy Vaadin framework version 7/8 ClientConnector implementations. This class maps the basic functionality required for connectors to work inside newer Vaadin versions (with Flow).
    Author:
    Vaadin Ltd
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void addExtension​(Extension extension)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      com.vaadin.flow.shared.Registration addLegacyAttachListener​(ClientConnector.AttachListener listener)
      Add a listener for legacy connector attach events.
      com.vaadin.flow.shared.Registration addLegacyDetachListener​(ClientConnector.DetachListener listener)
      Add a listener for connector detach events.
      com.vaadin.flow.shared.Registration addListener​(java.lang.Class<?> eventType, com.vaadin.flow.function.SerializableEventListener listener, java.lang.reflect.Method method)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected com.vaadin.flow.shared.Registration addListener​(java.lang.String eventIdentifier, java.lang.Class<?> eventType, com.vaadin.flow.function.SerializableEventListener listener, java.lang.reflect.Method method)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected void addMethodInvocationToQueue​(java.lang.String interfaceName, java.lang.reflect.Method method, java.lang.Object[] parameters)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      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 response is written to client side.
      protected SharedState createState()
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      void detach()
      Notifies the connector that it is detached from its VaadinSession.
      static java.lang.Iterable<? extends ClientConnector> getAllChildrenIterable​(ClientConnector connector)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      java.lang.String getConnectorId()
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode*
      com.vaadin.flow.server.ErrorHandler getErrorHandler()
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      java.util.Collection<Extension> getExtensions()
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected Resource getResource​(java.lang.String key)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected com.vaadin.flow.server.VaadinSession getSession()
      Finds the VaadinSession to which this connector belongs.
      protected SharedState getState()
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected SharedState getState​(boolean markAsDirty)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      boolean handleConnectorRequest​(com.vaadin.flow.server.VaadinRequest request, com.vaadin.flow.server.VaadinResponse response, java.lang.String path)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected boolean hasListeners​(java.lang.Class<? extends com.vaadin.flow.component.ComponentEvent> eventType)
      Checks if the given ComponentEvent type is listened for this component.
      boolean isAttached()
      Delegates to Component.isAttached().
      boolean isConnectorEnabled()
      Checks if the communicator is enabled.
      void markAsDirty()
      Marks that this classic component's state might have changed.
      void markAsDirtyRecursive()
      Causes this classic component and all child components below it to be marked as dirty.
      protected void onAttach​(com.vaadin.flow.component.AttachEvent attachEvent)  
      protected void onDetach​(com.vaadin.flow.component.DetachEvent detachEvent)  
      protected <T extends ServerRpc>
      void
      registerRpc​(T implementation)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected <T extends ServerRpc>
      void
      registerRpc​(T implementation, java.lang.Class<T> rpcInterfaceType)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      void removeExtension​(Extension extension)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      void setErrorHandler​(com.vaadin.flow.server.ErrorHandler errorHandler)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected void setResource​(java.lang.String key, Resource resource)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      protected void updateDiffstate​(java.lang.String propertyName, elemental.json.JsonValue newValue)
      Deprecated.
      not supported - calling this does nothing but logs a warning in development mode
      • Methods inherited from class com.vaadin.flow.component.Component

        addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.vaadin.flow.component.AttachNotifier

        addAttachListener
      • Methods inherited from interface com.vaadin.flow.component.DetachNotifier

        addDetachListener
    • Constructor Detail

      • AbstractClientConnector

        public AbstractClientConnector()
    • Method Detail

      • onAttach

        protected void onAttach​(com.vaadin.flow.component.AttachEvent attachEvent)
        Overrides:
        onAttach in class com.vaadin.flow.component.Component
      • onDetach

        protected void onDetach​(com.vaadin.flow.component.DetachEvent detachEvent)
        Overrides:
        onDetach in class com.vaadin.flow.component.Component
      • beforeClientResponse

        public void beforeClientResponse​(boolean initial)
        Description copied from interface: ClientConnector
        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 initial is false when the component is attached again to a new UI when PreserveOnRefresh is used.

        Specified by:
        beforeClientResponse in interface ClientConnector
        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.
      • markAsDirtyRecursive

        public void markAsDirtyRecursive()
        Description copied from interface: ClientConnector
        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.

        Specified by:
        markAsDirtyRecursive in interface ClientConnector
        See Also:
        ClientConnector.markAsDirty()
      • addLegacyAttachListener

        public com.vaadin.flow.shared.Registration addLegacyAttachListener​(ClientConnector.AttachListener listener)
        Description copied from interface: ClientConnector
        Add a listener for legacy connector attach events. This could be migrated to AttachNotifier.addAttachListener(ComponentEventListener).
        Specified by:
        addLegacyAttachListener in interface ClientConnector
        Parameters:
        listener - the listener to add
        Returns:
        Registration for unregistering the listener
      • addLegacyDetachListener

        public com.vaadin.flow.shared.Registration addLegacyDetachListener​(ClientConnector.DetachListener listener)
        Description copied from interface: ClientConnector
        Add a listener for connector detach events. This could be migrated to DetachNotifier.addDetachListener(ComponentEventListener)
        Specified by:
        addLegacyDetachListener in interface ClientConnector
        Parameters:
        listener - the listener to add
        Returns:
        Registration for unregistering the listener
      • hasListeners

        protected boolean hasListeners​(java.lang.Class<? extends com.vaadin.flow.component.ComponentEvent> eventType)
        Checks if the given ComponentEvent type is listened for this component.
        Parameters:
        eventType - the event type to be checked
        Returns:
        true if a listener is registered for the given event type
      • attach

        public void attach()
        Description copied from interface: ClientConnector
        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.

        Specified by:
        attach in interface ClientConnector
      • detach

        public void detach()
        Description copied from interface: ClientConnector
        Notifies the connector that it is detached from its VaadinSession.

        Specified by:
        detach in interface ClientConnector
      • isAttached

        public boolean isAttached()
        Delegates to Component.isAttached(). Checks if the connector is attached to a VaadinSession.
        Specified by:
        isAttached in interface ClientConnector
        Overrides:
        isAttached in class com.vaadin.flow.component.Component
        Returns:
        true if the component is attached to an active UI.
      • isConnectorEnabled

        public boolean isConnectorEnabled()
        Description copied from interface: ClientConnector
        Checks if the communicator is enabled. An enabled communicator is allowed to receive messages from its counter-part.
        Specified by:
        isConnectorEnabled in interface ClientConnector
        Returns:
        true if the connector can receive messages, false otherwise
      • getSession

        protected com.vaadin.flow.server.VaadinSession getSession()
        Finds the VaadinSession to which this connector belongs. If the connector has not been attached, null is returned.
        Returns:
        The connector's session, or null if not attached
      • addExtension

        @Deprecated
        protected void addExtension​(Extension extension)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        extension - extension
      • addListener

        @Deprecated
        public com.vaadin.flow.shared.Registration addListener​(java.lang.Class<?> eventType,
                                                               com.vaadin.flow.function.SerializableEventListener listener,
                                                               java.lang.reflect.Method method)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        eventType - event type
        listener - listener
        method - method
        Returns:
        registration that does nothing
      • addListener

        @Deprecated
        protected com.vaadin.flow.shared.Registration addListener​(java.lang.String eventIdentifier,
                                                                  java.lang.Class<?> eventType,
                                                                  com.vaadin.flow.function.SerializableEventListener listener,
                                                                  java.lang.reflect.Method method)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        eventIdentifier - event identifier
        eventType - event type
        listener - listener
        method - method
        Returns:
        a registration that does nothing
      • addMethodInvocationToQueue

        @Deprecated
        protected void addMethodInvocationToQueue​(java.lang.String interfaceName,
                                                  java.lang.reflect.Method method,
                                                  java.lang.Object[] parameters)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        interfaceName - interface name
        method - method
        parameters - parameters
      • createState

        @Deprecated
        protected SharedState createState()
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Returns:
        placeholder shared state
      • getAllChildrenIterable

        @Deprecated
        public static java.lang.Iterable<? extends ClientConnector> getAllChildrenIterable​(ClientConnector connector)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        connector - connector
        Returns:
        empty iterator
      • getConnectorId

        @Deprecated
        public java.lang.String getConnectorId()
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode*
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Returns:
        empty string
      • getErrorHandler

        @Deprecated
        public com.vaadin.flow.server.ErrorHandler getErrorHandler()
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Returns:
        error handler that does nothing
      • getExtensions

        @Deprecated
        public java.util.Collection<Extension> getExtensions()
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Returns:
        an empty collection
      • getResource

        @Deprecated
        protected Resource getResource​(java.lang.String key)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        key - key
        Returns:
        a fake resource object
      • getState

        @Deprecated
        protected SharedState getState()
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Returns:
        placeholder shared state
      • getState

        @Deprecated
        protected SharedState getState​(boolean markAsDirty)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        markAsDirty - mark as dirty
        Returns:
        placeholder shared state
      • handleConnectorRequest

        @Deprecated
        public boolean handleConnectorRequest​(com.vaadin.flow.server.VaadinRequest request,
                                              com.vaadin.flow.server.VaadinResponse response,
                                              java.lang.String path)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        request - request
        response - response
        path - path
        Returns:
        false
      • registerRpc

        @Deprecated
        protected <T extends ServerRpc> void registerRpc​(T implementation)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Type Parameters:
        T - type
        Parameters:
        implementation - implementation
      • registerRpc

        @Deprecated
        protected <T extends ServerRpc> void registerRpc​(T implementation,
                                                         java.lang.Class<T> rpcInterfaceType)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Type Parameters:
        T - type
        Parameters:
        implementation - implementation
        rpcInterfaceType - rpc interface type
      • removeExtension

        @Deprecated
        public void removeExtension​(Extension extension)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        extension - extension
      • setErrorHandler

        @Deprecated
        public void setErrorHandler​(com.vaadin.flow.server.ErrorHandler errorHandler)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        errorHandler - error handler
      • setResource

        @Deprecated
        protected void setResource​(java.lang.String key,
                                   Resource resource)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        key - key
        resource - resource
      • updateDiffstate

        @Deprecated
        protected void updateDiffstate​(java.lang.String propertyName,
                                       elemental.json.JsonValue newValue)
        Deprecated.
        not supported - calling this does nothing but logs a warning in development mode
        Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
        Parameters:
        propertyName - property name
        newValue - new value