You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2010/10/07 22:48:12 UTC

svn commit: r1005629 - in /myfaces/trinidad/trunk/trinidad-api/src/main: java/org/apache/myfaces/trinidad/change/ java/org/apache/myfaces/trinidad/util/ xrts/org/apache/myfaces/trinidad/resource/

Author: gcrawford
Date: Thu Oct  7 20:48:12 2010
New Revision: 1005629

URL: http://svn.apache.org/viewvc?rev=1005629&view=rev
Log:
TRINIDAD-1935 ChangeManager shouldn't persist changes for stamped components

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/BaseChangeManager.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/ChangeManager.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
    myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/BaseChangeManager.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/BaseChangeManager.java?rev=1005629&r1=1005628&r2=1005629&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/BaseChangeManager.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/BaseChangeManager.java Thu Oct  7 20:48:12 2010
@@ -23,6 +23,8 @@ import javax.faces.context.FacesContext;
 
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
+import org.apache.myfaces.trinidad.util.ComponentUtils;
+
 import org.w3c.dom.Document;
 
 
@@ -46,6 +48,12 @@ abstract class BaseChangeManager extends
     UIComponent uiComponent,
     ComponentChange change)
   {
+    if (ComponentUtils.isStampedComponent(facesContext, uiComponent)) 
+    {
+      _LOG.info("DONT_PERSIST_STAMPED_COMPONENT_INSIDE_ITERATOR");      
+      return;
+    }
+        
     if (facesContext == null || uiComponent == null || change == null)
       throw new IllegalArgumentException(_LOG.getMessage(
         "CANNOT_ADD_CHANGE_WITH_FACECONTEXT_OR_UICOMPONENT_OR_NULL"));

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/ChangeManager.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/ChangeManager.java?rev=1005629&r1=1005628&r2=1005629&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/ChangeManager.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/ChangeManager.java Thu Oct  7 20:48:12 2010
@@ -138,6 +138,9 @@ public abstract class ChangeManager
 
   /**
    * Add a ComponentChange to this current request for a specified component.
+   * When called we will disallow changes if the component or its any ancestor 
+   * is a stamped component by UIXIterator. 
+   *
    * @throws IllegalArgumentException if any of the supplied parameters were to
    *          be null.
    */
@@ -164,6 +167,9 @@ public abstract class ChangeManager
 
   /**
    * Add a DocumentChange to this current request for a specified component.
+   * When called we will allow changes even if the component or its any ancestor 
+   * is a stamped component by UIXIterator.
+   * 
    * @throws IllegalArgumentException if any of the supplied parameters were to
    *          be null.
    */

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java?rev=1005629&r1=1005628&r2=1005629&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java Thu Oct  7 20:48:12 2010
@@ -27,6 +27,9 @@ import javax.faces.component.UIComponent
 
 import javax.faces.component.UIViewRoot;
 
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.trinidad.component.UIXIterator;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
 /**
@@ -447,6 +450,29 @@ public final class ComponentUtils
     
     return builder.toString();
   }
+  
+  /**
+   * Checks if the component is a stamped component inside a UIXIterator. 
+   * 
+   * @param context FacesContext
+   * @param component 
+   * @return True if the component is inside a UIXIterator
+   */
+  public static boolean isStampedComponent(FacesContext context, UIComponent component) 
+  {
+    UIComponent parent = component.getParent();
+    UIComponent root = context.getViewRoot();
+    while (parent != root) 
+    {
+      if (parent instanceof UIXIterator) 
+      {
+        return true;
+      }
+      parent = parent.getParent();      
+    }
+
+    return false;
+  }
 
   /**
    * Builds the scoped id. Adds the naming container's id and the separator char

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts?rev=1005629&r1=1005628&r2=1005629&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts Thu Oct  7 20:48:12 2010
@@ -182,6 +182,9 @@
  
  <!-- NO_NODE_SPECIFIED -->
  <resource key="NO_NODE_SPECIFIED">No node specified</resource>
+
+ <!-- DONT_PERSIST_STAMPED_COMPONENT_INSIDE_ITERATOR-->
+ <resource key="DONT_PERSIST_STAMPED_COMPONENT_INSIDE_ITERATOR">We don't want to persist stamped component inside an iterator</resource>
  
  <!-- COMPONENT_REQUIRED -->
  <resource key="COMPONENT_REQUIRED">Component required</resource>