myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mstar...@apache.org
Subject svn commit: r1438118 - /myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java
Date Thu, 24 Jan 2013 18:27:13 GMT
Author: mstarets
Date: Thu Jan 24 18:27:13 2013
New Revision: 1438118

URL: http://svn.apache.org/viewvc?rev=1438118&view=rev
Log:
TRINIDAD-2302 - source component of ajax request is rendered without id (causing javascript
errors). Thanks, Thomas Moller for the patch!

Modified:
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java?rev=1438118&r1=1438117&r2=1438118&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java
(original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java
Thu Jan 24 18:27:13 2013
@@ -23,6 +23,9 @@ import java.io.IOException;
 import java.util.List;
 
 import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.AjaxBehavior;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.render.Renderer;
@@ -293,6 +296,27 @@ public class XhtmlRenderer
 
     return true;
   }
+  
+  private boolean hasAjaxBahavior(UIComponent component)
+  {
+    if (!(component instanceof ClientBehaviorHolder))
+    {
+      return false;
+    }
+    ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
+    for (List<ClientBehavior> behaviors : holder.getClientBehaviors().values())
+    {
+      for (ClientBehavior behavior : behaviors)
+      {
+        if (behavior instanceof AjaxBehavior)
+        {
+          return true;
+        }
+      }
+    }
+    
+    return false;
+  }
 
   /**
    * Returns true if the component should render an ID.  Components
@@ -303,6 +327,12 @@ public class XhtmlRenderer
   protected boolean shouldRenderId(FacesContext context,
     UIComponent component)
   {
+    // TRINIDAD-2303
+    if (hasAjaxBahavior(component))
+    {
+      return true;
+    }
+    
     // If there's partial triggers, always render an ID if possible
     if (getPartialTriggers(component, getFacesBean(component)) != null)
     {



Mime
View raw message