com.vaadin.event.

Class EventRouter

    • Constructor Detail

      • EventRouter

        public EventRouter()
    • Method Detail

      • addListener

        @Deprecated
        public Registration addListener​(Class<?> eventType,
                                        Object object,
                                        Method method)
        Deprecated.

        Description copied from interface: MethodEventSource

        Registers a new event 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.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        addListener in interface MethodEventSource

        Parameters:

        eventType - the type of the listened event. Events of this type or its subclasses activate the listener.

        object - the object instance who owns the activation method.

        method - the activation method.

        Returns:

        a registration object for removing the listener

      • addListener

        public Registration addListener​(Class<?> eventType,
                                        SerializableEventListener listener,
                                        Method method)

        Description copied from interface: MethodEventSource

        Registers a new event 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.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        addListener in interface MethodEventSource

        Parameters:

        eventType - the type of the listened event. Events of this type or its subclasses activate the listener.

        listener - the listener instance who owns the activation method.

        method - the activation method.

        Returns:

        a registration object for removing the listener

      • addListener

        @Deprecated
        public Registration addListener​(Class<?> eventType,
                                        Object target,
                                        Method method,
                                        String eventIdentifier,
                                        SharedState state)

        Registers a new event 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.

        This method additionally informs the event-api to stop routing events with the given eventIdentifier to the components handleEvent function call.

        The only way to remove the listener is to use the returned Registration. The other methods, e.g. removeAllListeners() do not do that.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        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.

        eventIdentifier - the identifier of the event to listen for

        state - The component State

        Returns:

        a registration object for removing the listener

        Throws:

        IllegalArgumentException - unless method has exactly one match in target

        NullPointerException - if target is null

        Since:

        8.2

      • addListener

        public Registration addListener​(Class<?> eventType,
                                        SerializableEventListener listener,
                                        Method method,
                                        String eventIdentifier,
                                        SharedState state)

        Registers a new event 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.

        This method additionally informs the event-api to stop routing events with the given eventIdentifier to the components handleEvent function call.

        The only way to remove the listener is to use the returned Registration. The other methods, e.g. removeAllListeners() do not do that.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Parameters:

        eventType - the type of the listened event. Events of this type or its subclasses activate the listener.

        listener - the listener instance who owns the activation method.

        method - the activation method.

        eventIdentifier - the identifier of the event to listen for

        state - The component State

        Returns:

        a registration object for removing the listener

        Throws:

        IllegalArgumentException - unless method has exactly one match in target

        NullPointerException - if target is null

        Since:

        8.12

      • addListener

        @Deprecated
        public Registration addListener​(Class<?> eventType,
                                        Object object,
                                        String methodName)
        Deprecated.

        Description copied from interface: MethodEventSource

        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.

        This version of addListener gets the name of the activation method as a parameter. The actual method is reflected from object, and unless exactly one match is found, java.lang.IllegalArgumentException is thrown.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        addListener in interface MethodEventSource

        Parameters:

        eventType - the type of the listened event. Events of this type or its subclasses activate the listener.

        object - the object instance who owns the activation method.

        methodName - the name of the activation method.

        Returns:

        a registration object for removing the listener

      • addListener

        public Registration addListener​(Class<?> eventType,
                                        SerializableEventListener listener,
                                        String methodName)

        Description copied from interface: MethodEventSource

        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.

        This version of addListener gets the name of the activation method as a parameter. The actual method is reflected from listener, and unless exactly one match is found, java.lang.IllegalArgumentException is thrown.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        addListener in interface MethodEventSource

        Parameters:

        eventType - the type of the listened event. Events of this type or its subclasses activate the listener.

        listener - the listener instance who owns the activation method.

        methodName - the name of the activation method.

        Returns:

        a registration object for removing the listener

      • removeListener

        @Deprecated
        public void removeListener​(Class<?> eventType,
                                   Object target)
        Deprecated.

        Description copied from interface: MethodEventSource

        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.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        removeListener in interface MethodEventSource

        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

        public void removeListener​(Class<?> eventType,
                                   SerializableEventListener listener)

        Description copied from interface: MethodEventSource

        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.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        removeListener in interface MethodEventSource

        Parameters:

        eventType - the exact event type the object listens to.

        listener - the listener that has registered to listen to events of type eventType with one or more methods.

      • removeListener

        @Deprecated
        public void removeListener​(Class<?> eventType,
                                   Object target,
                                   Method method)
        Deprecated.

        Description copied from interface: MethodEventSource

        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.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        removeListener in interface MethodEventSource

        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.

        method - the method owned by the target that's registered to listen to events of type eventType.

      • removeListener

        @Deprecated
        public void removeListener​(Class<?> eventType,
                                   Object target,
                                   String methodName)
        Deprecated.

        Description copied from interface: MethodEventSource

        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.

        This version of removeListener gets the name of the activation method as a parameter. The actual method is reflected from the target, and unless exactly one match is found, java.lang.IllegalArgumentException is thrown.

        For more information on the inheritable event mechanism see the com.vaadin.event package documentation.

        Specified by:

        removeListener in interface MethodEventSource

        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.

        methodName - the name of the method owned by target that's registered to listen to events of type eventType.

      • removeAllListeners

        public void removeAllListeners()

        Removes all listeners from event router.

      • fireEvent

        public void fireEvent​(EventObject event)

        Sends an event to all registered listeners. The listeners will decide if the activation method should be called or not.

        Parameters:

        event - the Event to be sent to all listeners.

      • fireEvent

        public void fireEvent​(EventObject event,
                              ErrorHandler errorHandler)

        Sends an event to all registered listeners. The listeners will decide if the activation method should be called or not.

        If an error handler is set, the processing of other listeners will continue after the error handler method call unless the error handler itself throws an exception.

        Parameters:

        event - the Event to be sent to all listeners.

        errorHandler - error handler to use to handle any exceptions thrown by listeners or null to let the exception propagate to the caller, preventing further listener calls

      • hasListeners

        public boolean hasListeners​(Class<?> eventType)

        Checks if the given Event type is listened by a listener registered to this router.

        Parameters:

        eventType - the event type to be checked

        Returns:

        true if a listener is registered for the given event type

      • getListeners

        public Collection<?> getListeners​(Class<?> eventType)

        Returns all listeners that match or extend the given event type.

        Parameters:

        eventType - The type of event to return listeners for.

        Returns:

        A collection with all registered listeners. Empty if no listeners are found.