public class EventRouter extends Object implements MethodEventSource
EventRouter class implementing the inheritable event listening
model. For more information on the event model see the
package documentation.| Constructor and Description |
|---|
EventRouter() |
| Modifier and Type | Method and Description |
|---|---|
Registration |
addListener(Class<?> eventType,
Object object,
Method method)
Deprecated.
|
Registration |
addListener(Class<?> eventType,
Object target,
Method method,
String eventIdentifier,
SharedState state)
Deprecated.
As of 8.12. Use
addListener(Class, SerializableEventListener, Method, String, SharedState)
instead |
Registration |
addListener(Class<?> eventType,
Object object,
String methodName)
Deprecated.
|
Registration |
addListener(Class<?> eventType,
SerializableEventListener listener,
Method method)
Registers a new event listener with the specified activation method to
listen events generated by this component.
|
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.
|
Registration |
addListener(Class<?> eventType,
SerializableEventListener listener,
String methodName)
Registers a new listener with the specified activation method to listen
events generated by this component.
|
void |
fireEvent(EventObject event)
Sends an event to all registered listeners.
|
void |
fireEvent(EventObject event,
ErrorHandler errorHandler)
Sends an event to all registered listeners.
|
Collection<?> |
getListeners(Class<?> eventType)
Returns all listeners that match or extend the given event type.
|
boolean |
hasListeners(Class<?> eventType)
Checks if the given Event type is listened by a listener registered to
this router.
|
void |
removeAllListeners()
Removes all listeners from event router.
|
void |
removeListener(Class<?> eventType,
Object target)
Deprecated.
|
void |
removeListener(Class<?> eventType,
Object target,
Method method)
Deprecated.
|
void |
removeListener(Class<?> eventType,
Object target,
String methodName)
Deprecated.
|
void |
removeListener(Class<?> eventType,
SerializableEventListener listener)
Removes all registered listeners matching the given parameters.
|
@Deprecated public Registration addListener(Class<?> eventType, Object object, Method method)
MethodEventSource
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
addListener in interface MethodEventSourceeventType - 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.public Registration addListener(Class<?> eventType, SerializableEventListener listener, Method method)
MethodEventSource
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
addListener in interface MethodEventSourceeventType - 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.@Deprecated public Registration addListener(Class<?> eventType, Object target, Method method, String eventIdentifier, SharedState state)
addListener(Class, SerializableEventListener, Method, String, SharedState)
instead
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.
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 forstate - The component StateIllegalArgumentException - unless method has exactly one match in targetNullPointerException - if target is nullpublic Registration addListener(Class<?> eventType, SerializableEventListener listener, Method method, String eventIdentifier, SharedState state)
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.
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 forstate - The component StateIllegalArgumentException - unless method has exactly one match in targetNullPointerException - if target is null@Deprecated public Registration addListener(Class<?> eventType, Object object, String methodName)
MethodEventSource
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.
addListener in interface MethodEventSourceeventType - 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.public Registration addListener(Class<?> eventType, SerializableEventListener listener, String methodName)
MethodEventSource
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.
addListener in interface MethodEventSourceeventType - the type of the listened event. Events of this type or its
subclasses activate the listener.methodName - the name of the activation method.@Deprecated public void removeListener(Class<?> eventType, Object target)
MethodEventSourceobject'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.
removeListener in interface MethodEventSourceeventType - 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.public void removeListener(Class<?> eventType, SerializableEventListener listener)
MethodEventSourceobject'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.
removeListener in interface MethodEventSourceeventType - 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.@Deprecated public void removeListener(Class<?> eventType, Object target, Method method)
MethodEventSource
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
removeListener in interface MethodEventSourceeventType - 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.@Deprecated public void removeListener(Class<?> eventType, Object target, String methodName)
MethodEventSource
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.
removeListener in interface MethodEventSourceeventType - 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.public void removeAllListeners()
public void fireEvent(EventObject event)
event - the Event to be sent to all listeners.public void fireEvent(EventObject event, ErrorHandler errorHandler)
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.
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 callspublic boolean hasListeners(Class<?> eventType)
eventType - the event type to be checkedpublic Collection<?> getListeners(Class<?> eventType)
eventType - The type of event to return listeners for.Copyright © 2022 Vaadin Ltd. All rights reserved.