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 2013/05/12 19:58:21 UTC
svn commit: r1481615 -
/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
Author: lu4242
Date: Sun May 12 17:58:20 2013
New Revision: 1481615
URL: http://svn.apache.org/r1481615
Log:
MYFACES-3721 Override of uniqueIdCounter for UIViewRoot in restoreView cause component duplicate id exception
Modified:
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java?rev=1481615&r1=1481614&r2=1481615&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java Sun May 12 17:58:20 2013
@@ -297,6 +297,9 @@ public class DefaultFaceletsStateManagem
if (state != null && state[1] != null)
{
states = (Map<String, Object>) state[1];
+ //Save the last unique id counter key in UIViewRoot
+ Long lastUniqueIdCounter = (Long) view.getAttributes().get(UNIQUE_ID_COUNTER_KEY);
+
// Visit the children and restore their state.
boolean emptyState = false;
boolean containsFaceletState = states.containsKey(
@@ -339,6 +342,18 @@ public class DefaultFaceletsStateManagem
{
view.getAttributes().put(ComponentSupport.FACELET_STATE_INSTANCE, faceletViewState);
}
+ if (lastUniqueIdCounter != null)
+ {
+ Long newUniqueIdCounter = (Long) view.getAttributes().get(UNIQUE_ID_COUNTER_KEY);
+ if (newUniqueIdCounter != null &&
+ lastUniqueIdCounter.longValue() > newUniqueIdCounter.longValue())
+ {
+ // The unique counter was restored by a side effect of
+ // restoreState() over UIViewRoot with a lower count,
+ // to avoid a component duplicate id exception we need to fix the count.
+ view.getAttributes().put(UNIQUE_ID_COUNTER_KEY, lastUniqueIdCounter);
+ }
+ }
handleDynamicAddedRemovedComponents(context, view, states);
}
}