myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1099263 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/DefaultRestoreViewSupport.java
Date Tue, 03 May 2011 21:26:10 GMT
Author: lu4242
Date: Tue May  3 21:26:10 2011
New Revision: 1099263

URL: http://svn.apache.org/viewvc?rev=1099263&view=rev
Log:
MYFACES-3124 Use both SKIP_ITERATION hints in RESTORE_VIEW (Thanks to Martin Koci for provide
this patch)

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/DefaultRestoreViewSupport.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/DefaultRestoreViewSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/DefaultRestoreViewSupport.java?rev=1099263&r1=1099262&r2=1099263&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/DefaultRestoreViewSupport.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/DefaultRestoreViewSupport.java
Tue May  3 21:26:10 2011
@@ -20,6 +20,7 @@ package org.apache.myfaces.lifecycle;
 
 import java.net.MalformedURLException;
 import java.util.Collections;
+import java.util.EnumSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.logging.Level;
@@ -31,6 +32,7 @@ import javax.faces.application.ViewHandl
 import javax.faces.component.UIComponent;
 import javax.faces.component.visit.VisitCallback;
 import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitHint;
 import javax.faces.component.visit.VisitResult;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
@@ -84,12 +86,24 @@ public class DefaultRestoreViewSupport i
         // JSF 2.0: Old hack related to t:aliasBean was fixed defining a event that traverse
         // whole tree and let components to override UIComponent.processEvent() method to
include it.
         
-        // TODO: Remove this hack and use VisitHints.SKIP_ITERATION in JSF 2.1
-        facesContext.getAttributes().put(SKIP_ITERATION_HINT, Boolean.TRUE);
-        
-        component.visitTree(VisitContext.createVisitContext(facesContext), new RestoreStateCallback());
+        // Remove this hack SKIP_ITERATION_HINT and use VisitHints.SKIP_ITERATION in JSF
2.1 only
+        // is not possible, because jsf 2.0 API-based libraries can use the String
+        // hint, JSF21-based libraries can use both.
+        try
+        {
+            facesContext.getAttributes().put(SKIP_ITERATION_HINT, Boolean.TRUE);
+
+            EnumSet<VisitHint> visitHints = EnumSet.of(VisitHint.SKIP_ITERATION);
+            VisitContext visitContext = VisitContext.createVisitContext(facesContext, null,
visitHints);
+            component.visitTree(visitContext, new RestoreStateCallback());
+        }
+        finally
+        {
+            // We must remove hint in finally, because an exception can break this phase,
+            // but lifecycle can continue, if custom exception handler swallows the exception
+            facesContext.getAttributes().remove(SKIP_ITERATION_HINT);
+        }
         
-        facesContext.getAttributes().remove(SKIP_ITERATION_HINT);
         
         /*
         ValueExpression binding = component.getValueExpression("binding");



Mime
View raw message