myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r772952 - /myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
Date Fri, 08 May 2009 12:13:14 GMT
Author: werpu
Date: Fri May  8 12:13:13 2009
New Revision: 772952

URL: http://svn.apache.org/viewvc?rev=772952&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2117

execude code added for the partial processing

Modified:
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java?rev=772952&r1=772951&r2=772952&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
Fri May  8 12:13:13 2009
@@ -18,14 +18,17 @@
  */
 package org.apache.myfaces.context.servlet;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
 
 import javax.faces.context.FacesContext;
 import javax.faces.context.PartialResponseWriter;
 import javax.faces.context.PartialViewContext;
 import javax.faces.event.PhaseId;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitHint;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.component.UIComponent;
 
 import org.apache.myfaces.shared_impl.util.StringUtils;
 
@@ -236,8 +239,19 @@
     public void processPartial(PhaseId phaseId)
     {
         assertNotReleased(METHOD_PROCESSPARTIAL);
-        //TODO: JSF 2.0, add impl
-        
+
+        UIComponent viewRoot = _facesContext.getViewRoot();
+
+        if (phaseId == PhaseId.APPLY_REQUEST_VALUES
+                || phaseId == PhaseId.PROCESS_VALIDATIONS
+                || phaseId == PhaseId.UPDATE_MODEL_VALUES)
+        {
+            Set<VisitHint> hints = new HashSet<VisitHint>();
+            hints.add(VisitHint.EXECUTE_LIFECYCLE);
+            hints.add(VisitHint.SKIP_UNRENDERED);
+            VisitContext visitCtx = VisitContext.createVisitContext(_facesContext, getRenderIds(),
hints);
+            viewRoot.visitTree(visitCtx, new PhaseAwareVisitCallback(_facesContext, phaseId));
+        }
     }
     
     /**
@@ -267,4 +281,33 @@
         _facesContext = null;
         _released = true;        
     }
+
+    private class PhaseAwareVisitCallback implements VisitCallback {
+        private PhaseId _phaseId;
+        private FacesContext _facesContext;
+
+        public PhaseAwareVisitCallback(FacesContext facesContext, PhaseId phaseId) {
+            this._phaseId = phaseId;
+            this._facesContext = facesContext;
+        }
+
+        @Override
+        public VisitResult visit(VisitContext context, UIComponent target) {
+            if (_phaseId == PhaseId.APPLY_REQUEST_VALUES)
+            {
+                target.processDecodes(_facesContext);
+            }
+            else if (_phaseId == PhaseId.PROCESS_VALIDATIONS)
+            {
+                target.processValidators(_facesContext);
+            }
+            else if (_phaseId == PhaseId.UPDATE_MODEL_VALUES)
+            {
+                target.processUpdates(_facesContext);
+            }
+
+            // Return VisitResult.REJECT as processDecodes/Validators/Updates already traverse
sub tree
+            return VisitResult.REJECT;
+        }
+    }
 }



Mime
View raw message