myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r1524142 - in /myfaces/trinidad/trunk/trinidad-api/src/main: java-templates/org/apache/myfaces/trinidad/component/ java/org/apache/myfaces/trinidad/component/
Date Tue, 17 Sep 2013 17:51:57 GMT
Author: jwaldman
Date: Tue Sep 17 17:51:56 2013
New Revision: 1524142

URL: http://svn.apache.org/r1524142
Log:
TRINIDAD-2398 add component tracking ability to RequestContext
Thanks to Jing Wu for the patch

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ComponentProcessingContext.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java?rev=1524142&r1=1524141&r2=1524142&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
Tue Sep 17 17:51:56 2013
@@ -47,6 +47,7 @@ import javax.validation.Validation;
 
 import org.apache.myfaces.trinidad.bean.FacesBean;
 import org.apache.myfaces.trinidad.bean.PropertyKey;
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
 import org.apache.myfaces.trinidad.util.LabeledFacesMessage;
@@ -244,6 +245,8 @@ abstract public class UIXEditableValueTe
     if (!isRendered())
       return;
 
+    RequestContext requestContext = RequestContext.getCurrentInstance();
+    requestContext.pushCurrentComponent(context, this);
     pushComponentToEL(context, this);
     try
     {
@@ -255,6 +258,7 @@ abstract public class UIXEditableValueTe
     finally
     {
       popComponentFromEL(context);
+      requestContext.popCurrentComponent(context, this);
     }
   }
 
@@ -265,6 +269,8 @@ abstract public class UIXEditableValueTe
     if (!isRendered())
       return;
 
+    RequestContext requestContext = RequestContext.getCurrentInstance();
+    requestContext.pushCurrentComponent(context, this);
     pushComponentToEL(context, this);
     try
     {
@@ -276,6 +282,7 @@ abstract public class UIXEditableValueTe
     finally
     {
       popComponentFromEL(context);
+      requestContext.popCurrentComponent(context, this);
     }
 
     if (!isValid())
@@ -291,6 +298,8 @@ abstract public class UIXEditableValueTe
     if (!isRendered())
       return;
 
+    RequestContext requestContext = RequestContext.getCurrentInstance();
+    requestContext.pushCurrentComponent(context, this);
     pushComponentToEL(context, this);
     try
     {
@@ -302,6 +311,7 @@ abstract public class UIXEditableValueTe
     finally
     {
       popComponentFromEL(context);
+      requestContext.popCurrentComponent(context, this);
     }
   }
 

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java?rev=1524142&r1=1524141&r2=1524142&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
Tue Sep 17 17:51:56 2013
@@ -39,6 +39,7 @@ import javax.faces.event.PhaseId;
 
 import javax.faces.render.Renderer;
 
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.model.CollectionModel;
 import org.apache.myfaces.trinidad.model.LocalRowKeyIndex;
 import org.apache.myfaces.trinidad.model.ModelUtils;
@@ -96,6 +97,8 @@ public abstract class UIXIteratorTemplat
           @Override
           protected void process(UIComponent kid, ComponentProcessingContext cpContext) throws
IOException
           {
+            RequestContext requestContext = cpContext.getRequestContext();
+            requestContext.pushCurrentComponent(context, kid);
             kid.pushComponentToEL(context, null);
 
             try
@@ -105,6 +108,7 @@ public abstract class UIXIteratorTemplat
             finally
             {
               kid.popComponentFromEL(context);
+              requestContext.popCurrentComponent(context, kid);
             }
           }
         };

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ComponentProcessingContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ComponentProcessingContext.java?rev=1524142&r1=1524141&r2=1524142&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ComponentProcessingContext.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ComponentProcessingContext.java
Tue Sep 17 17:51:56 2013
@@ -21,6 +21,8 @@ package org.apache.myfaces.trinidad.comp
 import java.util.Collections;
 import java.util.Set;
 
+import org.apache.myfaces.trinidad.context.RequestContext;
+
 /**
  * ProcessingContext passed to FlattenedComponents and ComponentProcessors representing the
  * current component iteration context.
@@ -35,6 +37,7 @@ public final class ComponentProcessingCo
 {
   ComponentProcessingContext()
   {      
+    _requestContext = RequestContext.getCurrentInstance();
   }
 
   /**
@@ -89,6 +92,11 @@ public final class ComponentProcessingCo
     return _hints;
   }
 
+  public RequestContext getRequestContext()
+  {
+    return _requestContext;
+  }
+
   /**
    * Increment the grouping and startGroup states.
    * <p>
@@ -130,7 +138,7 @@ public final class ComponentProcessingCo
   {
     _startDepth = 0;
   }
-  
+
   /**
    * Handshake from the UIXComponent
    */
@@ -142,4 +150,5 @@ public final class ComponentProcessingCo
   private int _startDepth;
   private int _groupDepth;
   private Set<ProcessingHint> _hints = Collections.emptySet();
+  private RequestContext _requestContext = null;
 }

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?rev=1524142&r1=1524141&r2=1524142&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
Tue Sep 17 17:51:56 2013
@@ -1247,6 +1247,8 @@ public abstract class UIXCollection exte
           __flushCachedModel();
         }
 
+        RequestContext requestContext = RequestContext.getCurrentInstance();
+        requestContext.pushCurrentComponent(context, this);
         pushComponentToEL(context, null);
 
         try
@@ -1256,6 +1258,7 @@ public abstract class UIXCollection exte
         finally
         {
           popComponentFromEL(context);
+          requestContext.popCurrentComponent(context, this);
         }
 
         invokedComponent = true;

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=1524142&r1=1524141&r2=1524142&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
Tue Sep 17 17:51:56 2013
@@ -166,60 +166,52 @@ abstract public class UIXComponent exten
   {
     if (child.isRendered())
     {
-      RequestContext requestContext = RequestContext.getCurrentInstance();
-      requestContext.pushCurrentComponent(context, child);
-      try
+       // component is an action FlattenedComponent.  Ask it to flatten its children
+      if ((child instanceof FlattenedComponent) &&
+          ((FlattenedComponent)child).isFlatteningChildren(context))
+      {
+        return ((FlattenedComponent)child).processFlattenedChildren(context,
+                                                                    cpContext,
+                                                                    childProcessor,
+                                                                    callbackContext);
+      }
+      else
       {
-
-         // component is an action FlattenedComponent.  Ask it to flatten its children
-        if ((child instanceof FlattenedComponent) &&
-            ((FlattenedComponent)child).isFlatteningChildren(context))
-        {
-          return ((FlattenedComponent)child).processFlattenedChildren(context,
-                                                                      cpContext,
-                                                                      childProcessor,
-                                                                      callbackContext);
-        }
-        else
+        boolean processed = true;
+        RequestContext requestContext = cpContext.getRequestContext();
+        requestContext.pushCurrentComponent(context, child);
+        child.pushComponentToEL(context, null);
+        try
         {
-          boolean processed = true;
-          child.pushComponentToEL(context, null);
-
-          try
+          if (isFlattenableCoreComponent(child))
+          {
+            processed =
+                processFlattenedChildren(context, cpContext, childProcessor,
+                                         child.getChildren(),
+                                         callbackContext);
+          }
+          else
           {
-            if (isFlattenableCoreComponent(child))
+            try
             {
-              processed =
-                  processFlattenedChildren(context, cpContext, childProcessor,
-                                           child.getChildren(),
-                                           callbackContext);
+              // not a FlattenedComponent, pass the component directly to the ComponentProcessor
+              childProcessor.processComponent(context, cpContext, child,
+                                              callbackContext);
             }
-            else
+            finally
             {
-              try
-              {
-                // not a FlattenedComponent, pass the component directly to the ComponentProcessor
-                childProcessor.processComponent(context, cpContext, child,
-                                                callbackContext);
-              }
-              finally
-              {
-                // if startDepth is > 0, only the first visible child will be marked as
starting a group
-                cpContext.resetStartDepth();
-              }
+              // if startDepth is > 0, only the first visible child will be marked as
starting a group
+              cpContext.resetStartDepth();
             }
           }
-          finally
-          {
-            child.popComponentFromEL(context);
-          }
-
-          return processed;
         }
-      }
-      finally
-      {
-        requestContext.popCurrentComponent(context, child);
+        finally
+        {
+          child.popComponentFromEL(context);
+          requestContext.popCurrentComponent(context, child);
+        }
+
+        return processed;
       }
     }
     else
@@ -355,14 +347,17 @@ abstract public class UIXComponent exten
   {
     UIComponent component = event.getComponent();
     UIComponent compositeParent = null;
+    RequestContext requestContext = RequestContext.getCurrentInstance();
     if (!UIComponent.isCompositeComponent(component))
     {
       compositeParent = UIComponent.getCompositeComponentParent(component);
       if (compositeParent != null) 
       {
+        requestContext.pushCurrentComponent(context, compositeParent);
         compositeParent.pushComponentToEL(context, null);
       }
     }
+    requestContext.pushCurrentComponent(context, component);
     component.pushComponentToEL(context, null);
     try
     {
@@ -371,9 +366,11 @@ abstract public class UIXComponent exten
     finally
     {
       component.popComponentFromEL(context);
+      requestContext.popCurrentComponent(context, component);
       if (compositeParent != null) 
       {
         compositeParent.popComponentFromEL(context);
+        requestContext.popCurrentComponent(context, compositeParent);
       }
     }
   }

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java?rev=1524142&r1=1524141&r2=1524142&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
Tue Sep 17 17:51:56 2013
@@ -2074,9 +2074,6 @@ abstract public class UIXComponentBase e
 
     boolean invokedComponent;
 
-    // push component to the stack before invoking the component.
-    RequestContext requestContext = RequestContext.getCurrentInstance();
-    requestContext.pushCurrentComponent(context, this);
     setupVisitingContext(context);
 
     try
@@ -2085,6 +2082,8 @@ abstract public class UIXComponentBase e
 
       if (clientId.equals(thisClientId))
       {
+        RequestContext requestContext = RequestContext.getCurrentInstance();
+        requestContext.pushCurrentComponent(context, this);
         pushComponentToEL(context, null);
 
         try
@@ -2095,6 +2094,7 @@ abstract public class UIXComponentBase e
         finally
         {
           popComponentFromEL(context);
+          requestContext.popCurrentComponent(context, this);
         }
 
         invokedComponent = true;
@@ -2121,9 +2121,6 @@ abstract public class UIXComponentBase e
     {
       // teardown the context now that we have visited the children
       tearDownVisitingContext(context);
-
-      // pop the component out from the stack after invoking this component.
-      requestContext.popCurrentComponent(context, this);
     }
 
     return invokedComponent;
@@ -2153,6 +2150,9 @@ abstract public class UIXComponentBase e
 
       if (clientId.equals(thisClientId))
       {
+        // push component to the stack before invoking the component.
+        RequestContext requestContext = RequestContext.getCurrentInstance();
+        requestContext.pushCurrentComponent(context, this);
         pushComponentToEL(context, null);
 
         try
@@ -2163,6 +2163,7 @@ abstract public class UIXComponentBase e
         finally
         {
           popComponentFromEL(context);
+          requestContext.popCurrentComponent(context, this);
         }
 
         // we found the component



Mime
View raw message