incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r499625 - in /incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component: StampState.java UIXCollection.java
Date Thu, 25 Jan 2007 00:16:51 GMT
Author: awiner
Date: Wed Jan 24 16:16:50 2007
New Revision: 499625

URL: http://svn.apache.org/viewvc?view=rev&rev=499625
Log:
ADFFACES-362: IndexOutOfBoundsException in UIXCollection.restoreStampState when transient
components are included

Part 2: the prior checkin fixed transient components that were inside of children of columns,
but made things
even worse for direct transient children of columns.  Now, both should work.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/StampState.java
    incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/StampState.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/StampState.java?view=diff&rev=499625&r1=499624&r2=499625
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/StampState.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/StampState.java
Wed Jan 24 16:16:50 2007
@@ -131,10 +131,20 @@
     List<UIComponent> kids = column.getChildren();
     int sz = kids.size();
     Object[] state = new Object[sz];
+    boolean wasAllTransient = true;
     for(int i=0; i<sz; i++)
     {
-      state[i] = table.saveStampState(context, kids.get(i));
-    }
+      Object childState = table.saveStampState(context, kids.get(i));
+      state[i] = childState;
+      if (childState != UIXCollection.Transient.TRUE)
+        wasAllTransient = false;
+    }
+    
+    // If all we found were transient components, just use
+    // an empty array
+    if (wasAllTransient)
+      return _EMPTY_ARRAY;
+
     return state;
   }
 
@@ -150,9 +160,18 @@
   {
     List<UIComponent> kids = column.getChildren();
     Object[] state = (Object[]) stampState;
+
+    int childIndex = 0;
     for(int i=0; i<state.length; i++)
     {
-      table.restoreStampState(context, kids.get(i), state[i]);
+      Object childState = state[i];
+      // Skip over any saved state that corresponds to transient
+      // components
+      if (childState == UIXCollection.Transient.TRUE)
+        continue;
+
+      table.restoreStampState(context, kids.get(childIndex), childState);
+      childIndex++;
     }
   }
 
@@ -432,4 +451,5 @@
      TrinidadLogger.createTrinidadLogger(StampState.class);
 
   private Map<DualKey, Object> _rows;
+  private static final Object[] _EMPTY_ARRAY = new Object[0];
 }

Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?view=diff&rev=499625&r1=499624&r2=499625
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
Wed Jan 24 16:16:50 2007
@@ -1315,5 +1315,5 @@
   // TODO: is this really better than just, say, using null for 
   // transient components?  It's certainly better at not papering
   // over error cases
-  private enum Transient { TRUE };
+  enum Transient { TRUE };
 }



Mime
View raw message