Interface FAbstractClientConnector

All Superinterfaces:
ClientConnector, Serializable
All Known Subinterfaces:
FAbstractComponent, FAbstractTextField
All Known Implementing Classes:
AbsoluteLayout, AbstractClientConnector, AbstractComponent, AbstractComponentContainer, AbstractField, AbstractLayout, AbstractOrderedLayout, AbstractSingleComponentContainer, ClickableRenderer, CssLayout, CustomComponent, CustomField, DateRenderer, FButton, FCheckBox, FComboBox, FComponentRenderer, FDateField, FGrid, FGrid.AbstractGridExtension, FGrid.AbstractRenderer, FImage, FListSelect, FMenuBar, FormLayout, FPasswordField, FTabSheet, FTextArea, FTextField, FTokenField, FTwinColSelect, GridLayout, HorizontalLayout, HtmlRenderer, ImageRenderer, Label, Panel, Table, TextRenderer, VerticalLayout

public interface FAbstractClientConnector extends ClientConnector, Serializable
An interface for legacy Vaadin framework version 7/8 ClientConnector implementations with default implementation. This class maps the basic functionality required for connectors to work inside newer Vaadin versions (with Flow).
Author:
Vaadin Ltd
  • Method Details

    • getFlowComponent

      default com.vaadin.flow.component.Component getFlowComponent()
      Returns the target Flow component that this interface implements.
      Returns:
      the target Flow component
      Throws:
      ClassCastException - if the target component is not a Component type
    • doConnectorOnAttach

      default void doConnectorOnAttach(com.vaadin.flow.component.AttachEvent attachEvent)
    • doConnectorOnDetach

      default void doConnectorOnDetach(com.vaadin.flow.component.DetachEvent detachEvent)
    • attach

      default 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

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

      Specified by:
      detach in interface ClientConnector
    • markAsDirty

      default void markAsDirty()
      Description copied from interface: ClientConnector
      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 run ClientConnector.beforeClientResponse(boolean) for all legacy components that are marked as dirty.
      Specified by:
      markAsDirty in interface ClientConnector
    • registerInternalBeforeClientResponse

      static void registerInternalBeforeClientResponse(FAbstractClientConnector connector, com.vaadin.flow.component.Component component)
    • isBeforeClientResponseRegistered

      static boolean isBeforeClientResponseRegistered(com.vaadin.flow.component.Component component)
    • beforeClientResponse

      default 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.
    • isAttached

      default boolean isAttached()
      Delegates to Component.isAttached(). Checks if the connector is attached to a VaadinSession.
      Specified by:
      isAttached in interface ClientConnector
      Returns:
      true if the component is attached to an active UI.
    • markAsDirtyRecursive

      default 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:
    • addLegacyAttachListener

      default 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

      default 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
    • removeAttachListener

      default void removeAttachListener(ClientConnector.AttachListener listener)
    • removeDetachListener

      default void removeDetachListener(ClientConnector.DetachListener listener)
    • isConnectorEnabled

      default 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
    • hasListeners

      default boolean hasListeners(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
    • getFListeners

      default Collection<?> getFListeners(Class<? extends com.vaadin.flow.component.ComponentEvent> eventType)
      Checks if the given Event 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
    • addListener

      default com.vaadin.flow.shared.Registration addListener(String eventIdentifier, Class<?> eventType, Object target, Method method)

      Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.

      Parameters:
      eventIdentifier - the identifier of the event to listen for (not used in feature pack)
      eventType - the type of the listened event. Events of this type or its subclasses activate the listener.
      target - the object instance who owns the activation method.
      method - the activation method.
    • addListener

      default com.vaadin.flow.shared.Registration addListener(Class<?> eventType, Object target, Method method)

      Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.

      Parameters:
      eventType - the type of the listened event. Events of this type or its subclasses activate the listener.
      target - the object instance who owns the activation method.
      method - the activation method.
    • removeListener

      default void removeListener(Class<?> eventType, Object target)
      Removes all registered listeners matching the given parameters. Since this method receives the event type and the listener object as parameters, it will unregister all object's methods that are registered to listen to events of type eventType generated by this component.
      Parameters:
      eventType - the exact event type the object listens to.
      target - the target object that has registered to listen to events of type eventType with one or more methods.
    • removeListener

      default void removeListener(Class<?> eventType, Object target, Method method)
      Removes one registered listener method. The given method owned by the given object will no longer be called when the specified events are generated by this component.
      Parameters:
      eventType - the exact event type the object listens to.
      target - target object that has registered to listen to events of type eventType with one or more methods.
      method - the method owned by target that's registered to listen to events of type eventType.
    • fireEvent

      default void fireEvent(EventObject event)
      Sends the event to all Vaadin 7/8 style method invoking listeners added with addListener(Class, Object, Method).
      Parameters:
      event - the Event to be sent to all listeners.
    • fireEvent

      default void fireEvent(EventObject event, com.vaadin.flow.component.ComponentEventBus eventBus)
      Sends the event to all Vaadin 7/8 style method invoking listeners added with addListener(Class, Object, Method). If given event type has a regular Flow component event listener registered, then event is fired as a regular event without V7/8 method invoking.
      Parameters:
      event - the Event to be sent to all listeners.
      eventBus - the event bus to use for firing the event
    • getAllChildrenIterable

      default Iterable<? extends ClientConnector> getAllChildrenIterable(ClientConnector connector)
      Get an Iterable for iterating over all child connectors, including child components.
      Parameters:
      connector - the connector to get children for
      Returns:
      an Iterable giving all child connectors.
    • getResource

      default Resource getResource(String key)
      Gets a resource defined using setResource(String, Resource) with the corresponding key.
      Parameters:
      key - the string identifier of the resource
      Returns:
      a resource, or null if there's no resource associated with the given key
      See Also:
    • setResource

      default void setResource(String key, Resource resource)
      Registers a resource with this connector using the given key. Saves the resource in server-side component state so that it can be accessed later. Making resource available also to the client-side is not applicable with Flow. Use StreamResource with Element API like Element.setAttribute(String, AbstractStreamResource) instead.
      Parameters:
      key - the string key to associate the resource with
      resource - the resource to set, or null to clear a previous association.