You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/11/26 23:29:42 UTC
svn commit: r1039580 -
/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java
Author: lu4242
Date: Fri Nov 26 22:29:42 2010
New Revision: 1039580
URL: http://svn.apache.org/viewvc?rev=1039580&view=rev
Log:
MYFACES-2973 UIComponent.unsubscribeFromEvent calls getApplication().unsubscribeFromEvent() instead of modifying _systemEventListenerClassMap
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java?rev=1039580&r1=1039579&r2=1039580&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java Fri Nov 26 22:29:42 2010
@@ -708,8 +708,9 @@ public abstract class UIComponent implem
* (and thus must be removed), the equals() method on the existing listener must be invoked, passing the
* argument componentListener, rather than the other way around.
*
- * What is that supposed to mean? Are we supposed to keep an internal map of created listener wrappers? TODO:
- * Check with the EG what's the meaning of this, equals should be commutative -= Simon Lessard =-
+ * -=Simon Lessard=- What is that supposed to mean? Are we supposed to keep an internal map of created listener wrappers?
+ * -= Leonardo Uribe=- Yes, it is supposed a wrapper should be used to hold listener references, to prevent
+ * serialize component instances on the state.
*/
if (eventClass == null)
{
@@ -720,9 +721,23 @@ public abstract class UIComponent implem
throw new NullPointerException("componentListener required");
}
- SystemEventListener listener = new EventListenerWrapper(this, componentListener);
-
- getFacesContext().getApplication().unsubscribeFromEvent(eventClass, listener);
+ if (_systemEventListenerClassMap != null)
+ {
+ List<SystemEventListener> listeners = _systemEventListenerClassMap.get(eventClass);
+
+ if (listeners != null && !listeners.isEmpty())
+ {
+ for (Iterator<SystemEventListener> it = listeners.iterator(); it.hasNext();)
+ {
+ ComponentSystemEventListener listener = ((EventListenerWrapper) it.next()).getComponentSystemEventListener();
+ if (listener != null && listener.equals(componentListener))
+ {
+ it.remove();
+ break;
+ }
+ }
+ }
+ }
}
/**
@@ -1095,6 +1110,11 @@ public abstract class UIComponent implem
return source.getClass().isAssignableFrom(componentClass);
}
+
+ public ComponentSystemEventListener getComponentSystemEventListener()
+ {
+ return listener;
+ }
public void processEvent(SystemEvent event)
{