com.vaadin.client.ui.

Class AbstractConnector

    • Constructor Detail

      • AbstractConnector

        public AbstractConnector()
    • Method Detail

      • getConnectorId

        public String getConnectorId()

        Description copied from interface: Connector

        Returns the id for this connector. This is set by the framework and does not change during the lifetime of a connector.

        Specified by:

        getConnectorId in interface Connector

        Returns:

        The id for the connector.

      • doInit

        public final void doInit​(String connectorId,
                                 ApplicationConnection connection)

        Called once by the framework to initialize the connector.

        Note that the shared state is not yet available when this method is called.

        Connector classes should override init() instead of this method.

        Specified by:

        doInit in interface ServerConnector

      • init

        protected void init()

        Called when the connector has been initialized. Override this method to perform initialization of the connector.

      • registerRpc

        protected <T extends ClientRpc> void registerRpc​(Class<T> rpcInterface,
                                                         T implementation)

        Registers an implementation for a server to client RPC interface. Multiple registrations can be made for a single interface, in which case all of them receive corresponding RPC calls.

        Type Parameters:

        T - The type of the RPC interface that is being registered

        Parameters:

        rpcInterface - RPC interface

        implementation - implementation that should receive RPC calls

      • unregisterRpc

        protected <T extends ClientRpc> void unregisterRpc​(Class<T> rpcInterface,
                                                           T implementation)

        Unregisters an implementation for a server to client RPC interface.

        Type Parameters:

        T - The type of the RPC interface that is being unregistered

        Parameters:

        rpcInterface - RPC interface

        implementation - implementation to unregister

      • getRpcProxy

        protected <T extends ServerRpc> T getRpcProxy​(Class<T> rpcInterface)

        Returns an RPC proxy object which can be used to invoke the RPC method on the server.

        Type Parameters:

        T - The type of the ServerRpc interface

        Parameters:

        rpcInterface - The ServerRpc interface to retrieve a proxy object for

        Returns:

        A proxy object which can be used to invoke the RPC method on the server.

      • getRpcImplementations

        public <T extends ClientRpcCollection<T> getRpcImplementations​(String rpcInterfaceId)

        Description copied from interface: ServerConnector

        For internal use by the framework: returns the registered RPC implementations for an RPC interface identifier. TODO interface identifier type or format may change

        Specified by:

        getRpcImplementations in interface ServerConnector

        Parameters:

        rpcInterfaceId - RPC interface identifier: fully qualified interface type name

        Returns:

        RPC interface implementations registered for an RPC interface, not null

      • fireEvent

        public void fireEvent​(com.google.gwt.event.shared.GwtEvent<?> event)

        Description copied from interface: ServerConnector

        Sends the given event to all registered handlers.

        Specified by:

        fireEvent in interface ServerConnector

        Parameters:

        event - The event to send.

      • ensureHandlerManager

        protected com.google.gwt.event.shared.HandlerManager ensureHandlerManager()

        Ensure there is a handler manager. If one doesn't exist before this method is called, it gets created.

        Returns:

        the handler manager

      • addStateChangeHandler

        public com.google.gwt.event.shared.HandlerRegistration addStateChangeHandler​(StateChangeEvent.StateChangeHandler handler)

        Description copied from interface: ServerConnector

        Adds a handler that is called whenever any part of the state has been updated by the server.

        Specified by:

        addStateChangeHandler in interface ServerConnector

        Parameters:

        handler - The handler that should be added.

        Returns:

        A handler registration reference that can be used to unregister the handler

      • addStateChangeHandler

        public com.google.gwt.event.shared.HandlerRegistration addStateChangeHandler​(String propertyName,
                                                                                     StateChangeEvent.StateChangeHandler handler)

        Description copied from interface: ServerConnector

        Adds a handler that is called whenever the given part of the state has been updated by the server.

        Specified by:

        addStateChangeHandler in interface ServerConnector

        Parameters:

        propertyName - the name of the property for which the handler should be called

        handler - The handler that should be added.

        Returns:

        A handler registration reference that can be used to unregister the handler

      • removeStateChangeHandler

        public void removeStateChangeHandler​(String propertyName,
                                             StateChangeEvent.StateChangeHandler handler)

        Description copied from interface: ServerConnector

        Removes a handler that is called whenever any part of the state has been updated by the server.

        Specified by:

        removeStateChangeHandler in interface ServerConnector

        Parameters:

        propertyName - the name of the property for which the handler should be called

        handler - The handler that should be removed.

      • getState

        public SharedState getState()

        Returns the shared state object for this connector. Override this method to define the shared state type for your connector.

        Specified by:

        getState in interface ServerConnector

        Returns:

        the current shared state (never null)

      • createState

        protected SharedState createState()

        Creates a state object with default values for this connector. The created state object must be compatible with the return type of getState(). The default implementation creates a state object using GWT.create() using the defined return type of getState().

        Returns:

        A new state object

      • getStateType

        public static Type getStateType​(ServerConnector connector)

        Find the type of the state for the given connector.

        Parameters:

        connector - the connector whose state type to find

        Returns:

        the state type

      • setParent

        public void setParent​(ServerConnector parent)

        Description copied from interface: ServerConnector

        Sets the parent for this connector. This method should only be called by the framework to ensure that the connector hierarchy on the client side and the server side are in sync.

        Note that calling this method does not fire a ConnectorHierarchyChangeEvent. The event is fired only when the whole hierarchy has been updated.

        Specified by:

        setParent in interface ServerConnector

        Parameters:

        parent - The new parent of the connector

      • getChildren

        public List<ServerConnector> getChildren()

        Description copied from interface: ServerConnector

        Returns the child connectors for this connector (child components and extensions).

        Note that the method HasComponentsConnector.getChildComponents() can be used to obtain the subset of child connectors that correspond to components and not extensions.

        Specified by:

        getChildren in interface ServerConnector

        Returns:

        A collection of child connectors (components or extensions) for this connector. An empty collection if there are no children. Never returns null.

      • setChildren

        public void setChildren​(List<ServerConnector> children)

        Description copied from interface: ServerConnector

        Sets the children for this connector. This method should only be called by the framework to ensure that the connector hierarchy on the client side and the server side are in sync.

        Note that this method is separate from HasComponentsConnector.setChildComponents(List) and takes both extensions and child components. Both methods are called separately by the framework if the connector can have child components.

        Specified by:

        setChildren in interface ServerConnector

        Parameters:

        children - The new child connectors (extensions and/or components)

      • isEnabled

        public boolean isEnabled()

        Description copied from interface: ServerConnector

        Tests whether the connector is enabled or not. This method checks that the connector is enabled in context, i.e. if the parent connector is disabled, this method must return false.

        Specified by:

        isEnabled in interface ServerConnector

        Returns:

        true if the connector is enabled, false otherwise

      • getResourceUrl

        public String getResourceUrl​(String key)

        Gets the URL for a resource that has been added by the server-side connector using com.vaadin.terminal.AbstractClientConnector#setResource(String, com.vaadin.terminal.Resource) with the same key. null is returned if no corresponding resource is found.

        Parameters:

        key - a string identifying the resource.

        Returns:

        the resource URL as a string, or null if no corresponding resource is found.

      • hasEventListener

        public boolean hasEventListener​(String eventIdentifier)

        Description copied from interface: ServerConnector

        Checks if an event listener has been registered on the server side for the given event identifier.

        Specified by:

        hasEventListener in interface ServerConnector

        Parameters:

        eventIdentifier - The identifier for the event

        Returns:

        true if a listener has been registered on the server side, false otherwise

      • forceStateChange

        public void forceStateChange()

        Force the connector to recheck its state variables as the variables or their meaning might have changed.

        Since:

        7.3