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 2009/11/21 02:12:41 UTC

svn commit: r882814 - /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java

Author: lu4242
Date: Sat Nov 21 01:12:40 2009
New Revision: 882814

URL: http://svn.apache.org/viewvc?rev=882814&view=rev
Log:
fix ClientBehaviorHolder castings that in some test cases causes exceptions.

Modified:
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?rev=882814&r1=882813&r2=882814&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java Sat Nov 21 01:12:40 2009
@@ -281,37 +281,34 @@
     public static void decodeClientBehaviors(FacesContext facesContext,
             UIComponent component)
     {
-        if (!(component instanceof ClientBehaviorHolder))
+        if (component instanceof ClientBehaviorHolder)
         {
-            throw new IllegalArgumentException("Component "
-                    + component.getClientId(facesContext)
-                    + " is not an ClientBehaviorHolder");
-        }
-        ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
-        
-        Map<String,List<ClientBehavior>> clientBehaviors = 
-            clientBehaviorHolder.getClientBehaviors();
-                    
-        if (clientBehaviors != null && !clientBehaviors.isEmpty())
-        {
-            Map<String,String> paramMap = facesContext.getExternalContext().
-                getRequestParameterMap();
-            
-            String behaviorEventName = paramMap.get("javax.faces.behavior.event");
+            ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
             
-            if (behaviorEventName != null)
+            Map<String,List<ClientBehavior>> clientBehaviors = 
+                clientBehaviorHolder.getClientBehaviors();
+                        
+            if (clientBehaviors != null && !clientBehaviors.isEmpty())
             {
-                List<ClientBehavior> clientBehaviorList = clientBehaviors.get(behaviorEventName);
+                Map<String,String> paramMap = facesContext.getExternalContext().
+                    getRequestParameterMap();
+                
+                String behaviorEventName = paramMap.get("javax.faces.behavior.event");
                 
-                if (clientBehaviorList != null && !clientBehaviorList.isEmpty())
+                if (behaviorEventName != null)
                 {
-                    String clientId = paramMap.get("javax.faces.source");
+                    List<ClientBehavior> clientBehaviorList = clientBehaviors.get(behaviorEventName);
                     
-                    if (component.getClientId().equals(clientId))
+                    if (clientBehaviorList != null && !clientBehaviorList.isEmpty())
                     {
-                        for (ClientBehavior clientBehavior : clientBehaviorList)
+                        String clientId = paramMap.get("javax.faces.source");
+                        
+                        if (component.getClientId().equals(clientId))
                         {
-                            clientBehavior.decode(facesContext, component);
+                            for (ClientBehavior clientBehavior : clientBehaviorList)
+                            {
+                                clientBehavior.decode(facesContext, component);
+                            }
                         }
                     }
                 }
@@ -2277,7 +2274,7 @@
             UIComponent component, Map<String, List<ClientBehavior>> clientBehaviors, String eventName, String componentProperty, 
             String htmlAttrName) throws IOException
     {
-        List<ClientBehavior> cbl = clientBehaviors.get(eventName);
+        List<ClientBehavior> cbl = (clientBehaviors != null) ? clientBehaviors.get(eventName) : null;
         
         if (cbl == null || cbl.size() == 0)
         {