You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2012/02/04 00:31:25 UTC

svn commit: r1240400 - /myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java

Author: arobinson74
Date: Fri Feb  3 23:31:25 2012
New Revision: 1240400

URL: http://svn.apache.org/viewvc?rev=1240400&view=rev
Log:
TRINIDAD-2203 - Fixes for issues with the previous implementation

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=1240400&r1=1240399&r2=1240400&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java Fri Feb  3 23:31:25 2012
@@ -948,11 +948,11 @@ abstract public class UIXComponent exten
         throw new IllegalStateException(errorMessage);
       }
 
-      // Next, add a context change so that the flags are reset during an invokeOnComponent,
-      // or a visitTree call:
+      // Next, add a context change so that the flags are reset during an
+      // invokeOnComponent(context, clientId, callback), or a visitTree call:
       ComponentContextManager componentContextManager =
         RequestContext.getCurrentInstance().getComponentContextManager();
-      componentContextManager.pushChange(new DebugContextChange(this));
+      componentContextManager.pushChange(new VisitDebugContextChange(this));
       _inVisitingContext = true;
       _setupVisitingCaller = _getStackTraceElementForCaller();
     }
@@ -984,6 +984,14 @@ abstract public class UIXComponent exten
         throw new IllegalStateException(errorMessage);
       }
 
+      // Next, add a context change so that the flags are reset during an
+      // invokeOnComponent(context, clientId, callback), or a visitTree call
+      // (Note that a separate one is needed for the children due to the fact that currently
+      // the encoding context / visiting context is not set up during normal tree traversal,
+      // but the children encoding context is setup by the renderers):
+      ComponentContextManager componentContextManager =
+        RequestContext.getCurrentInstance().getComponentContextManager();
+      componentContextManager.pushChange(new VisitChildrenDebugContextChange(this));
       _inChildrenVisitingContext = true;
       _setupChildrenVisitingCaller = _getStackTraceElementForCaller();
     }
@@ -1022,8 +1030,8 @@ abstract public class UIXComponent exten
       ComponentContextChange contextChange = componentContextManager.popChange();
 
       // Validate the state of the context change stack:
-      if (!(contextChange instanceof DebugContextChange) ||
-          ((DebugContextChange)contextChange)._component != this)
+      if (!(contextChange instanceof VisitDebugContextChange) ||
+          ((VisitDebugContextChange)contextChange)._component != this)
       {
         String errorMessage = _LOG.getMessage("INVALID_CONTEXT_CHANGE_FOUND");
         throw new IllegalStateException(errorMessage);
@@ -1059,6 +1067,19 @@ abstract public class UIXComponent exten
         throw new IllegalStateException(errorMessage);
       }
 
+      // Next, remove the context change that was added in setupChildrenVisitingContext:
+      ComponentContextManager componentContextManager =
+        RequestContext.getCurrentInstance().getComponentContextManager();
+
+      ComponentContextChange contextChange = componentContextManager.popChange();
+      // Validate the state of the context change stack:
+      if (!(contextChange instanceof VisitChildrenDebugContextChange) ||
+          ((VisitChildrenDebugContextChange)contextChange)._component != this)
+      {
+        String errorMessage = _LOG.getMessage("INVALID_CONTEXT_CHANGE_FOUND");
+        throw new IllegalStateException(errorMessage);
+      }
+
       _inChildrenVisitingContext = false;
       _tearDownChildrenVisitingCaller = _getStackTraceElementForCaller();
     }
@@ -1418,10 +1439,10 @@ abstract public class UIXComponent exten
     return UIPanel.class == componentClass;
   }
 
-  private static class DebugContextChange
+  private static class VisitDebugContextChange
     extends ComponentContextChange
   {
-    private DebugContextChange(
+    private VisitDebugContextChange(
       UIXComponent     component)
     {
       _component = component;
@@ -1431,45 +1452,81 @@ abstract public class UIXComponent exten
     public void resume(FacesContext facesContext)
     {
       _component._inVisitingContext = _inVisitingContext;
-      _component._inChildrenVisitingContext = _inChildrenVisitingContext;
       _component._inEncodingContext = _inEncodingContext;
-      _component._inChildrenEncodingContext = _inChildrenEncodingContext;
       _component._setupVisitingCaller = _setupVisitingCaller;
       _component._tearDownVisitingCaller = _tearDownVisitingCaller;
       _component._setupEncodingCaller = _setupEncodingCaller;
       _component._tearDownEncodingCaller = _tearDownEncodingCaller;
-      _component._setupChildrenEncodingCaller = _setupChildrenEncodingCaller;
-      _component._tearDownChildrenEncodingCaller = _tearDownChildrenEncodingCaller;
-      _component._setupChildrenVisitingCaller = _setupChildrenVisitingCaller;
-      _component._tearDownChildrenVisitingCaller = _tearDownChildrenVisitingCaller;
     }
 
     @Override
     public void suspend(FacesContext facesContext)
     {
       _inVisitingContext = _component._inVisitingContext;
-      _inChildrenVisitingContext = _component._inChildrenVisitingContext;
       _inEncodingContext = _component._inEncodingContext;
-      _inChildrenEncodingContext = _component._inChildrenEncodingContext;
       _setupVisitingCaller = _component._setupVisitingCaller;
       _tearDownVisitingCaller = _component._tearDownVisitingCaller;
       _setupEncodingCaller = _component._setupEncodingCaller;
       _tearDownEncodingCaller = _component._tearDownEncodingCaller;
-      _setupChildrenEncodingCaller = _component._setupChildrenEncodingCaller;
-      _tearDownChildrenEncodingCaller = _component._tearDownChildrenEncodingCaller;
-      _setupChildrenVisitingCaller = _component._setupChildrenVisitingCaller;
-      _tearDownChildrenVisitingCaller = _component._tearDownChildrenVisitingCaller;
+
+      _component._inVisitingContext = false;
+      _component._inEncodingContext = false;
+      _component._setupVisitingCaller = null;
+      _component._tearDownVisitingCaller = null;
+      _component._setupEncodingCaller = null;
+      _component._tearDownEncodingCaller = null;
     }
 
     private final UIXComponent _component;
     private boolean _inVisitingContext;
-    private boolean _inChildrenVisitingContext;
     private boolean _inEncodingContext;
-    private boolean _inChildrenEncodingContext;
     private String _setupVisitingCaller;
     private String _tearDownVisitingCaller;
     private String _setupEncodingCaller;
     private String _tearDownEncodingCaller;
+  }
+
+  private static class VisitChildrenDebugContextChange
+    extends ComponentContextChange
+  {
+    private VisitChildrenDebugContextChange(
+      UIXComponent     component)
+    {
+      _component = component;
+    }
+
+    @Override
+    public void resume(FacesContext facesContext)
+    {
+      _component._inChildrenVisitingContext = _inChildrenVisitingContext;
+      _component._inChildrenEncodingContext = _inChildrenEncodingContext;
+      _component._setupChildrenEncodingCaller = _setupChildrenEncodingCaller;
+      _component._tearDownChildrenEncodingCaller = _tearDownChildrenEncodingCaller;
+      _component._setupChildrenVisitingCaller = _setupChildrenVisitingCaller;
+      _component._tearDownChildrenVisitingCaller = _tearDownChildrenVisitingCaller;
+    }
+
+    @Override
+    public void suspend(FacesContext facesContext)
+    {
+      _inChildrenVisitingContext = _component._inChildrenVisitingContext;
+      _inChildrenEncodingContext = _component._inChildrenEncodingContext;
+      _setupChildrenEncodingCaller = _component._setupChildrenEncodingCaller;
+      _tearDownChildrenEncodingCaller = _component._tearDownChildrenEncodingCaller;
+      _setupChildrenVisitingCaller = _component._setupChildrenVisitingCaller;
+      _tearDownChildrenVisitingCaller = _component._tearDownChildrenVisitingCaller;
+
+      _component._inChildrenVisitingContext = false;
+      _component._inChildrenEncodingContext = false;
+      _component._setupChildrenEncodingCaller = null;
+      _component._tearDownChildrenEncodingCaller = null;
+      _component._setupChildrenVisitingCaller = null;
+      _component._tearDownChildrenVisitingCaller = null;
+    }
+
+    private final UIXComponent _component;
+    private boolean _inChildrenVisitingContext;
+    private boolean _inChildrenEncodingContext;
     private String _setupChildrenEncodingCaller;
     private String _tearDownChildrenEncodingCaller;
     private String _setupChildrenVisitingCaller;