myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r905791 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/EventHandler.java
Date Tue, 02 Feb 2010 20:56:29 GMT
Author: lu4242
Date: Tue Feb  2 20:56:27 2010
New Revision: 905791

URL: http://svn.apache.org/viewvc?rev=905791&view=rev
Log:
MYFACES-2522 f:event wrong attribute name

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/EventHandler.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/EventHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/EventHandler.java?rev=905791&r1=905790&r2=905791&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/EventHandler.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/EventHandler.java
Tue Feb  2 20:56:27 2010
@@ -127,59 +127,60 @@
                 getValue (context.getFacesContext().getELContext());
         }
         
-        if (type != null) {
-            Collection<Class<? extends ComponentSystemEvent>> events;
-            
-            // We can look up the event class by name in the NamedEventManager.
+        Collection<Class<? extends ComponentSystemEvent>> events;
+        
+        // We can look up the event class by name in the NamedEventManager.
+        
+        events = NamedEventManager.getInstance().getNamedEvent (value);
+        
+        if (events == null)
+        {
+            try
+            {
+                eventClass = ReflectionUtil.forName (value);
+            }
+            catch (Throwable e)
+            {
+                throw new TagAttributeException (type, "Couldn't create event class", e);
+            }
+        }
+        else if (events.size() > 1)
+        {
+            StringBuilder classNames = new StringBuilder ("[");
+            Iterator<Class<? extends ComponentSystemEvent>> eventIterator = events.iterator();
             
-            events = NamedEventManager.getInstance().getNamedEvent (value);
+            // TODO: The spec is somewhat vague, but I think we're supposed to throw an exception
+            // here.  The @NamedEvent javadocs say that if a short name is registered to
more than one
+            // event class that we must throw an exception listing the short name and the
classes in
+            // the list _when the application makes reference to it_.  I believe processing
this tag
+            // qualifies as the application "making reference" to the short name.  Why the
exception
+            // isn't thrown when processing the @NamedEvent annotation, I don't know.  Perhaps
follow
+            // up with the EG to see if this is correct.
             
-            if (events.size() > 1) {
-                StringBuilder classNames = new StringBuilder ("[");
-                Iterator<Class<? extends ComponentSystemEvent>> eventIterator
= events.iterator();
-                
-                // TODO: The spec is somewhat vague, but I think we're supposed to throw
an exception
-                // here.  The @NamedEvent javadocs say that if a short name is registered
to more than one
-                // event class that we must throw an exception listing the short name and
the classes in
-                // the list _when the application makes reference to it_.  I believe processing
this tag
-                // qualifies as the application "making reference" to the short name.  Why
the exception
-                // isn't thrown when processing the @NamedEvent annotation, I don't know.
 Perhaps follow
-                // up with the EG to see if this is correct.
+            while (eventIterator.hasNext())
+            {
+                classNames.append (eventIterator.next().getName());
                 
-                while (eventIterator.hasNext()) {
-                    classNames.append (eventIterator.next().getName());
-                    
-                    if (eventIterator.hasNext()) {
-                        classNames.append (", ");
-                    }
-                    
-                    else {
-                        classNames.append ("]");
-                    }
+                if (eventIterator.hasNext())
+                {
+                    classNames.append (", ");
+                }
+                else
+                {
+                    classNames.append ("]");
                 }
-                
-                throw new FacesException ("The event name '" + value + "' is mapped to more
than one " +
-                    " event class: " + classNames.toString());
             }
             
-            else {
-                eventClass = events.iterator().next();
-            }
+            throw new FacesException ("The event name '" + value + "' is mapped to more than
one " +
+                " event class: " + classNames.toString());
         }
-        
-        else {
-            // Must have been defined via the "type" attribute, so instantiate the class.
-            
-            try {
-                eventClass = ReflectionUtil.forName (value);
-            }
-        
-            catch (Throwable e) {
-                throw new TagAttributeException (type, "Couldn't create event class", e);
-            }
+        else
+        {
+            eventClass = events.iterator().next();
         }
         
-        if (!ComponentSystemEvent.class.isAssignableFrom (eventClass)) {
+        if (!ComponentSystemEvent.class.isAssignableFrom (eventClass))
+        {
             throw new TagAttributeException (type, "Event class " + eventClass.getName()
+
                 " is not of type javax.faces.event.ComponentSystemEvent");
         }



Mime
View raw message