From 40570e17319d96adcfebaaa8c98b1e16f58902f0 Mon Sep 17 00:00:00 2001
From: Tatu Lund
+ * This method additionally informs the event-api to stop routing events + * with the given {@code eventIdentifier} to the components handleEvent + * function call. + *
+ * + *+ * The only way to remove the listener is to use the returned + * {@link Registration}. The other methods, e.g. + * {@link #removeAllListeners()} do not do that. + *
+ * + *+ * For more information on the inheritable event mechanism see the + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + * @param eventType + * the type of the listened event. Events of this type or its + * subclasses activate the listener. + * @param listener + * the listener instance who owns the activation method. + * @param method + * the activation method. + * @param eventIdentifier + * the identifier of the event to listen for + * @param state + * The component State + * @return a registration object for removing the listener + * @throws IllegalArgumentException + * unless {@code method} has exactly one match in {@code target} + * @throws NullPointerException + * if {@code target} is {@code null} + * @since 8.12 + */ + public Registration addListener(Class> eventType, + SerializableEventListener listener, Method method, + String eventIdentifier, SharedState state) { + if (listenerList == null) { + listenerList = new LinkedHashSet<>(); + } + ListenerMethod listenerMethod = new ListenerMethod(eventType, listener, + method); + listenerList.add(listenerMethod); + + Registration registration = ComponentStateUtil + .addRegisteredEventListener(state, eventIdentifier); + + return () -> { + listenerList.remove(listenerMethod); + if (!hasListeners(eventType)) { + registration.remove(); + } + }; + } + /* * Registers a new listener with the specified named activation method to * listen events generated by this component. Don't add a JavaDoc comment * here, we use the default documentation from implemented interface. */ + @Deprecated @Override public Registration addListener(Class> eventType, Object object, String methodName) { Objects.requireNonNull(object, "Listener must not be null."); + getLogger().log(Level.WARNING, "Adding listeners with type Object is" + + " deprecated, event listener should extend SerializableEventListener"); if (listenerList == null) { listenerList = new LinkedHashSet<>(); } @@ -145,12 +239,31 @@ public class EventRouter implements MethodEventSource { return () -> listenerList.remove(listenerMethod); } + /* + * Registers a new listener with the specified named activation method to + * listen events generated by this component. Don't add a JavaDoc comment + * here, we use the default documentation from implemented interface. + */ + @Override + public Registration addListener(Class> eventType, + SerializableEventListener listener, String methodName) { + Objects.requireNonNull(listener, "Listener must not be null."); + if (listenerList == null) { + listenerList = new LinkedHashSet<>(); + } + ListenerMethod listenerMethod = new ListenerMethod(eventType, listener, + methodName); + listenerList.add(listenerMethod); + return () -> listenerList.remove(listenerMethod); + } + /* * Removes all registered listeners matching the given parameters. Don't add * a JavaDoc comment here, we use the default documentation from implemented * interface. */ @Override + @Deprecated public void removeListener(Class> eventType, Object target) { if (listenerList != null) { final Iteratormethod
is not a member of target
- * .
+ * if method
is not a member of target
.
*/
+ @Deprecated
public ListenerMethod(Class> eventType, Object target, Method method,
Object[] arguments, int eventArgumentIndex)
throws IllegalArgumentException {
@@ -207,6 +207,45 @@ public class ListenerMethod implements EventListener, Serializable {
this.eventArgumentIndex = eventArgumentIndex;
}
+ /**
+ * + * Constructs a new event listener from a trigger method, it's arguments and + * the argument index specifying which one is replaced with the event object + * when the trigger method is called. + *
+ * + *+ * This constructor gets the trigger method as a parameter so it does not + * need to reflect to find it out. + *
+ * + * @param eventType + * the event type that is listener listens to. All events of this + * kind (or its subclasses) result in calling the trigger method. + * @param listener + * the listener instance that contains the trigger method + * @param method + * the trigger method + * @param arguments + * the arguments to be passed to the trigger method + * @param eventArgumentIndex + * An index to the argument list. This index points out the + * argument that is replaced with the event object before the + * argument set is passed to the trigger method. If the + * eventArgumentIndex is negative, the triggering event object + * will not be passed to the trigger method, though it is still + * called. + * @throws IllegalArgumentException + * ifmethod
is not a member of target
.
+ */
+ public ListenerMethod(Class> eventType,
+ SerializableEventListener listener, Method method,
+ Object[] arguments, int eventArgumentIndex)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, method, arguments,
+ eventArgumentIndex);
+ }
+
/**
*
* Constructs a new event listener from a trigger method name, it's
@@ -238,6 +277,7 @@ public class ListenerMethod implements EventListener, Serializable {
* unless exactly one match methodName
is found in
* target
.
*/
+ @Deprecated
public ListenerMethod(Class> eventType, Object target, String methodName,
Object[] arguments, int eventArgumentIndex)
throws IllegalArgumentException {
@@ -275,6 +315,45 @@ public class ListenerMethod implements EventListener, Serializable {
this.eventArgumentIndex = eventArgumentIndex;
}
+ /**
+ *
+ * Constructs a new event listener from a trigger method name, it's
+ * arguments and the argument index specifying which one is replaced with
+ * the event object. The actual trigger method is reflected from
+ * object
, and java.lang.IllegalArgumentException
+ * is thrown unless exactly one match is found.
+ *
java.lang.IllegalArgumentException
is thrown.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @param eventArgumentIndex
+ * An index to the argument list. This index points out the
+ * argument that is replaced with the event object before the
+ * argument set is passed to the trigger method. If the
+ * eventArgumentIndex is negative, the triggering event object
+ * will not be passed to the trigger method, though it is still
+ * called.
+ * @throws IllegalArgumentException
+ * unless exactly one match methodName
is found in
+ * target
.
+ */
+ public ListenerMethod(Class> eventType,
+ SerializableEventListener listener, String methodName,
+ Object[] arguments, int eventArgumentIndex)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, methodName, arguments,
+ eventArgumentIndex);
+ }
+
/**
*
* Constructs a new event listener from the trigger method and it's
@@ -298,9 +377,9 @@ public class ListenerMethod implements EventListener, Serializable {
* @param arguments
* the arguments to be passed to the trigger method.
* @throws IllegalArgumentException
- * if method
is not a member of target
- * .
+ * if method
is not a member of target
.
*/
+ @Deprecated
public ListenerMethod(Class> eventType, Object target, Method method,
Object[] arguments) throws IllegalArgumentException {
@@ -318,6 +397,37 @@ public class ListenerMethod implements EventListener, Serializable {
eventArgumentIndex = -1;
}
+ /**
+ *
+ * Constructs a new event listener from the trigger method and it's + * arguments. Since the the index to the replaced parameter is not specified + * the event triggering this listener will not be passed to the trigger + * method. + *
+ * + *+ * This constructor gets the trigger method as a parameter so it does not + * need to reflect to find it out. + *
+ * + * @param eventType + * the event type that is listener listens to. All events of this + * kind (or its subclasses) result in calling the trigger method. + * @param listener + * the listener instance that contains the trigger method. + * @param method + * the trigger method. + * @param arguments + * the arguments to be passed to the trigger method. + * @throws IllegalArgumentException + * ifmethod
is not a member of target
.
+ */
+ public ListenerMethod(Class> eventType,
+ SerializableEventListener listener, Method method,
+ Object[] arguments) throws IllegalArgumentException {
+ this(eventType, (Object) listener, method, arguments);
+ }
+
/**
*
* Constructs a new event listener from a trigger method name and it's
@@ -347,6 +457,7 @@ public class ListenerMethod implements EventListener, Serializable {
* unless exactly one match methodName
is found in
* object
.
*/
+ @Deprecated
public ListenerMethod(Class> eventType, Object target, String methodName,
Object[] arguments) throws IllegalArgumentException {
@@ -368,6 +479,41 @@ public class ListenerMethod implements EventListener, Serializable {
eventArgumentIndex = -1;
}
+ /**
+ *
+ * Constructs a new event listener from a trigger method name and it's + * arguments. Since the the index to the replaced parameter is not specified + * the event triggering this listener will not be passed to the trigger + * method. + *
+ * + *
+ * The actual trigger method is reflected from listener
, and
+ * java.lang.IllegalArgumentException
is thrown unless exactly
+ * one match is found.
+ *
java.lang.IllegalArgumentException
is thrown.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @throws IllegalArgumentException
+ * unless exactly one match methodName
is found in
+ * object
.
+ */
+ public ListenerMethod(Class> eventType,
+ SerializableEventListener listener, String methodName,
+ Object[] arguments) throws IllegalArgumentException {
+ this(eventType, (Object) listener, methodName, arguments);
+ }
+
/**
*
* Constructs a new event listener from a trigger method. Since the argument
@@ -388,9 +534,9 @@ public class ListenerMethod implements EventListener, Serializable {
* @param method
* the trigger method.
* @throws IllegalArgumentException
- * if method
is not a member of object
- * .
+ * if method
is not a member of object
.
*/
+ @Deprecated
public ListenerMethod(Class> eventType, Object target, Method method)
throws IllegalArgumentException {
@@ -420,6 +566,34 @@ public class ListenerMethod implements EventListener, Serializable {
}
}
+ /**
+ *
+ * Constructs a new event listener from a trigger method. Since the argument + * list is unspecified no parameters are passed to the trigger method when + * the listener is triggered. + *
+ * + *+ * This constructor gets the trigger method as a parameter so it does not + * need to reflect to find it out. + *
+ * + * @param eventType + * the event type that is listener listens to. All events of this + * kind (or its subclasses) result in calling the trigger method. + * @param listener + * the listener instance that contains the trigger method. + * @param method + * the trigger method. + * @throws IllegalArgumentException + * ifmethod
is not a member of object
.
+ */
+ public ListenerMethod(Class> eventType,
+ SerializableEventListener listener, Method method)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, method);
+ }
+
/**
*
* Constructs a new event listener from a trigger method name. Since the
@@ -446,6 +620,7 @@ public class ListenerMethod implements EventListener, Serializable {
* unless exactly one match methodName
is found in
* target
.
*/
+ @Deprecated
public ListenerMethod(Class> eventType, Object target, String methodName)
throws IllegalArgumentException {
@@ -479,6 +654,38 @@ public class ListenerMethod implements EventListener, Serializable {
}
}
+ /**
+ *
+ * Constructs a new event listener from a trigger method name. Since the + * argument list is unspecified no parameters are passed to the trigger + * method when the listener is triggered. + *
+ * + *
+ * The actual trigger method is reflected from listener
, and
+ * java.lang.IllegalArgumentException
is thrown unless exactly
+ * one match is found.
+ *
java.lang.IllegalArgumentException
is thrown.
+ * @throws IllegalArgumentException
+ * unless exactly one match methodName
is found in
+ * target
.
+ */
+ public ListenerMethod(Class> eventType,
+ SerializableEventListener listener, String methodName)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, methodName);
+ }
+
/**
* Receives one event from the EventRouter
and calls the
* trigger method if it matches with the criteria defined for the listener.
@@ -555,7 +762,7 @@ public class ListenerMethod implements EventListener, Serializable {
* @return true
if target
is the same object as
* the one stored in this object, eventType
equals with
* the event type stored in this object and method
- * equals with the method stored in this object
+ * equals with the method stored in this object.
*/
public boolean matches(Class> eventType, Object target, Method method) {
return (this.target == target) && (eventType.equals(this.eventType)
diff --git a/server/src/main/java/com/vaadin/event/MethodEventSource.java b/server/src/main/java/com/vaadin/event/MethodEventSource.java
index 33e61b842e..a4dfa89332 100644
--- a/server/src/main/java/com/vaadin/event/MethodEventSource.java
+++ b/server/src/main/java/com/vaadin/event/MethodEventSource.java
@@ -62,9 +62,39 @@ public interface MethodEventSource extends Serializable {
* if {@code object} is {@code null}
* @since 8.0
*/
+ @Deprecated
public Registration addListener(Class> eventType, Object object,
Method method);
+ /**
+ * 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 + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + * @param eventType + * the type of the listened event. Events of this type or its + * subclasses activate the listener. + * @param listener + * the listener instance who owns the activation method. + * @param method + * the activation method. + * @return a registration object for removing the listener + * @throws IllegalArgumentException + * unlessmethod
has exactly one match in
+ * object
+ * @throws NullPointerException
+ * if {@code object} is {@code null}
+ * @since 8.12
+ */
+ public Registration addListener(Class> eventType,
+ SerializableEventListener listener, Method method);
+
/**
* Registers a new listener with the specified activation method to listen
* events generated by this component. If the activation method does not
@@ -98,9 +128,46 @@ public interface MethodEventSource extends Serializable {
* if {@code object} is {@code null}
* @since 8.0
*/
+ @Deprecated
public Registration addListener(Class> eventType, Object object,
String methodName);
+ /**
+ * 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 + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + * @param eventType + * the type of the listened event. Events of this type or its + * subclasses activate the listener. + * @param listener + * the listener instance who owns the activation method. + * @param methodName + * the name of the activation method. + * @return a registration object for removing the listener + * @throws IllegalArgumentException + * unlessmethod
has exactly one match in
+ * object
+ * @throws NullPointerException
+ * if {@code object} is {@code null}
+ * @since 8.12
+ */
+ public Registration addListener(Class> eventType,
+ SerializableEventListener object, String methodName);
+
/**
* Removes all registered listeners matching the given parameters. Since
* this method receives the event type and the listener object as
@@ -119,8 +186,31 @@ public interface MethodEventSource extends Serializable {
* the target object that has registered to listen to events of
* type eventType
with one or more methods.
*/
+ @Deprecated
public 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.
+ *
+ * + * For more information on the inheritable event mechanism see the + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + * @param eventType + * the exact event type theobject
listens to.
+ * @param listener
+ * the listener that has registered to listen to events of type
+ * eventType
with one or more methods.
+ * @since 8.12
+ */
+ public void removeListener(Class> eventType,
+ SerializableEventListener listener);
+
/**
* Removes one registered listener method. The given method owned by the
* given object will no longer be called when the specified events are
diff --git a/server/src/main/java/com/vaadin/event/SortEvent.java b/server/src/main/java/com/vaadin/event/SortEvent.java
index dc3211bda7..ace8683959 100644
--- a/server/src/main/java/com/vaadin/event/SortEvent.java
+++ b/server/src/main/java/com/vaadin/event/SortEvent.java
@@ -80,7 +80,7 @@ public class SortEvent+ * This method additionally informs the event-api to route events with the + * given eventIdentifier to the components handleEvent function call. + *
+ * + *+ * For more information on the inheritable event mechanism see the + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + * @param eventIdentifier + * the identifier of the event to listen for + * @param eventType + * the type of the listened event. Events of this type or its + * subclasses activate the listener. + * @param listener + * the listener instance who owns the activation method. + * @param method + * the activation method. + * @return a registration object for removing the listener + * @since 8.12 + */ + protected Registration addListener(String eventIdentifier, + Class> eventType, SerializableEventListener listener, + Method method) { + if (eventRouter == null) { + eventRouter = new EventRouter(); + } + return eventRouter.addListener(eventType, listener, method, + eventIdentifier, getState()); + } + /** * Checks if the given {@link Event} type is listened for this component. * @@ -823,6 +865,10 @@ public abstract class AbstractClientConnector * For more information on the inheritable event mechanism see the * {@link com.vaadin.event com.vaadin.event package documentation}. * + * + * @deprecated As of 8.12. Use strongly typed + * {@link #addListener(Class, SerializableEventListener, Method)} + * method instead. * * @param eventType * the type of the listened event. Events of this type or its @@ -834,6 +880,7 @@ public abstract class AbstractClientConnector * @return a registration object for removing the listener */ @Override + @Deprecated public Registration addListener(Class> eventType, Object target, Method method) { if (eventRouter == null) { @@ -842,6 +889,37 @@ public abstract class AbstractClientConnector return eventRouter.addListener(eventType, target, 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. + * + *+ * For more information on the inheritable event mechanism see the + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + * @param eventType + * the type of the listened event. Events of this type or its + * subclasses activate the listener. + * @param listener + * the listener instance who owns the activation method. + * @param method + * the activation method. + * @return a registration object for removing the listener + * @since 8.12 + */ + + @Override + public Registration addListener(Class> eventType, + SerializableEventListener listener, Method method) { + if (eventRouter == null) { + eventRouter = new EventRouter(); + } + return eventRouter.addListener(eventType, listener, method); + } + /** * Convenience method for registering a new listener with the specified * activation method to listen events generated by this component. If the @@ -874,8 +952,10 @@ public abstract class AbstractClientConnector * the name of the activation method. * @return a registration object for removing the listener * @deprecated As of 7.0. This method should be avoided. Use - * {@link #addListener(Class, Object, Method)} or - * {@link #addListener(String, Class, Object, Method)} instead. + * {@link #addListener(Class, SerializableEventListener, Method)} + * or + * {@link #addListener(String, Class, SerializableEventListener, Method)} + * instead. * @since 8.0 */ @Override @@ -888,6 +968,56 @@ public abstract class AbstractClientConnector return eventRouter.addListener(eventType, target, methodName); } + /** + * Convenience method for registering 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 + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + *+ * Note: Using this method is discouraged because it cannot be checked + * during compilation. Use {@link #addListener(Class, Object, Method)} or + * {@link #addListener(String, Class, Object, Method) instead.
+ * + * @param eventType + * the type of the listened event. Events of this type or its + * subclasses activate the listener. + * @param listener + * the object instance who owns the activation method. + * @param methodName + * the name of the activation method. + * @return a registration object for removing the listener + * @deprecated This method has only been added for ease of migration and + * should be avoided in new code. + * Use + * {@link #addListener(Class, SerializableEventListener, Method)} + * or + * {@link #addListener(String, Class, SerializableEventListener, Method)} + * instead. + * @since 8.12 + */ + @Override + @Deprecated + public Registration addListener(Class> eventType, + SerializableEventListener listener, String methodName) { + if (eventRouter == null) { + eventRouter = new EventRouter(); + } + return eventRouter.addListener(eventType, listener, methodName); + } + /** * Removes all registered listeners matching the given parameters. Since * this method receives the event type and the listener object as @@ -916,6 +1046,36 @@ public abstract class AbstractClientConnector } } + /** + * Removes all registered listeners matching the given parameters. Since + * this method receives the event type and the listener object as + * parameters, it will unregister allobject
'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 + * {@link com.vaadin.event com.vaadin.event package documentation}. + *
+ * + * @param eventType + * the exact event type theobject
listens to.
+ * @param listener
+ * the listener that has registered to listen to events of type
+ * eventType
with one or more methods.
+ * @deprecated use a {@link Registration} from {@link #addListener} to
+ * remove a listener
+ * @since 8.12
+ */
+ @Deprecated
+ @Override
+ public void removeListener(Class> eventType,
+ SerializableEventListener listener) {
+ if (eventRouter != null) {
+ eventRouter.removeListener(eventType, listener);
+ }
+ }
+
/**
* Removes one registered listener method. The given method owned by the
* given object will no longer be called when the specified events are
diff --git a/server/src/main/java/com/vaadin/server/BootstrapListener.java b/server/src/main/java/com/vaadin/server/BootstrapListener.java
index f525c6aa4d..24b97f12a7 100644
--- a/server/src/main/java/com/vaadin/server/BootstrapListener.java
+++ b/server/src/main/java/com/vaadin/server/BootstrapListener.java
@@ -16,11 +16,10 @@
package com.vaadin.server;
-import java.io.Serializable;
-import java.util.EventListener;
-
import javax.portlet.RenderResponse;
+import com.vaadin.event.SerializableEventListener;
+
/**
* Event listener notified when the bootstrap HTML is about to be generated and
* send to the client. The bootstrap HTML is first constructed as an in-memory
@@ -30,7 +29,7 @@ import javax.portlet.RenderResponse;
* @author Vaadin Ltd
* @since 7.0.0
*/
-public interface BootstrapListener extends EventListener, Serializable {
+public interface BootstrapListener extends SerializableEventListener {
/**
* Lets this listener make changes to the fragment that makes up the actual
* Vaadin application. In a typical Servlet deployment, this is the contents
diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java
index 925df59121..0708a23000 100644
--- a/server/src/main/java/com/vaadin/server/Page.java
+++ b/server/src/main/java/com/vaadin/server/Page.java
@@ -30,6 +30,7 @@ import java.util.List;
import com.vaadin.annotations.HtmlImport;
import com.vaadin.annotations.StyleSheet;
import com.vaadin.event.EventRouter;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.ui.PageClientRpc;
@@ -54,7 +55,7 @@ public class Page implements Serializable {
* @see #addBrowserWindowResizeListener(BrowserWindowResizeListener)
*/
@FunctionalInterface
- public interface BrowserWindowResizeListener extends Serializable {
+ public interface BrowserWindowResizeListener extends SerializableEventListener {
/**
* Invoked when the browser window containing a UI has been resized.
*
@@ -259,7 +260,7 @@ public class Page implements Serializable {
*/
@Deprecated
@FunctionalInterface
- public interface UriFragmentChangedListener extends Serializable {
+ public interface UriFragmentChangedListener extends SerializableEventListener {
/**
* Event handler method invoked when the URI fragment of the page
* changes. Please note that the initial URI fragment has already been
@@ -286,7 +287,7 @@ public class Page implements Serializable {
* @since 8.0
*/
@FunctionalInterface
- public interface PopStateListener extends Serializable {
+ public interface PopStateListener extends SerializableEventListener {
/**
* Event handler method invoked when the URI fragment of the page
* changes. Please note that the initial URI fragment has already been
@@ -566,18 +567,18 @@ public class Page implements Serializable {
this.state = state;
}
- private Registration addListener(Class> eventType, Object target,
+ private Registration addListener(Class> eventType, SerializableEventListener listener,
Method method) {
if (!hasEventRouter()) {
eventRouter = new EventRouter();
}
- return eventRouter.addListener(eventType, target, method);
+ return eventRouter.addListener(eventType, listener, method);
}
- private void removeListener(Class> eventType, Object target,
+ private void removeListener(Class> eventType, SerializableEventListener listener,
Method method) {
if (hasEventRouter()) {
- eventRouter.removeListener(eventType, target, method);
+ eventRouter.removeListener(eventType, listener, method);
}
}
diff --git a/server/src/main/java/com/vaadin/ui/Button.java b/server/src/main/java/com/vaadin/ui/Button.java
index 8e98d73f3b..3308cba1b4 100644
--- a/server/src/main/java/com/vaadin/ui/Button.java
+++ b/server/src/main/java/com/vaadin/ui/Button.java
@@ -16,7 +16,6 @@
package com.vaadin.ui;
-import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collection;
@@ -24,6 +23,7 @@ import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
import com.vaadin.event.Action;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutAction.ModifierKey;
@@ -303,7 +303,7 @@ public class Button extends AbstractFocusable
* @since 3.0
*/
@FunctionalInterface
- public interface ClickListener extends Serializable {
+ public interface ClickListener extends SerializableEventListener {
public static final Method BUTTON_CLICK_METHOD = ReflectTools
.findMethod(ClickListener.class, "buttonClick",
diff --git a/server/src/main/java/com/vaadin/ui/HasComponents.java b/server/src/main/java/com/vaadin/ui/HasComponents.java
index d4a4375dd9..6987a3e7a6 100644
--- a/server/src/main/java/com/vaadin/ui/HasComponents.java
+++ b/server/src/main/java/com/vaadin/ui/HasComponents.java
@@ -19,6 +19,7 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Iterator;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.shared.Registration;
import com.vaadin.util.ReflectTools;
@@ -98,7 +99,7 @@ public interface HasComponents extends Component, Iterable