You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:30:46 UTC

[myfaces-trinidad] 23/36: Handle case the the VisitContext.ALL_IDS is returned from the VisitContext, since it doesn't support getSize().

This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1.2.12.2-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit c7a2ca1e87d486a98e5fdc82657ff790a43b0a27
Author: Blake Sullivan <bs...@apache.org>
AuthorDate: Thu Feb 25 18:42:12 2010 +0000

    Handle case the the VisitContext.ALL_IDS is returned from the VisitContext, since it doesn't support getSize().
---
 .../trinidad/component/UIXIteratorTemplate.java    | 122 +++++++++++++--------
 1 file changed, 76 insertions(+), 46 deletions(-)

diff --git a/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java b/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
index 85bafad..20a5f28 100644
--- a/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
+++ b/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
@@ -260,73 +260,103 @@ public abstract class UIXIteratorTemplate extends UIXCollection implements Flatt
   {
     Collection<String> subtreeIds = visitContext.getSubtreeIdsToVisit(this);
  
-    String ourClientIdPrefix = getClientId(visitContext.getFacesContext());
-   
-    int subtreeIdCount = subtreeIds.size();
-    
-    // build up a set of the row keys to visit rather than iterating
-    // and visiting every row
-    Set<String> rowsToVisit;
+    // create a special VisitContext that doesn't visit the Facets
+    // of column components since they aren't visited on each row
+    final VisitContext noColumnFacetContext = new NoColumnFacetsVisitContext(visitContext);
+
+    // runner to use to process the rows
+    Runner runner;
     
-    if (subtreeIdCount > 1)
+    if (VisitContext.ALL_IDS.equals(subtreeIds))
     {
-      rowsToVisit = new HashSet<String>(subtreeIdCount);
-
-      for (String currClientId : subtreeIds)
+      // we're processing all of the rows, so use the indexed runner (plus, we can't call size() on
+      // the ALL_IDS collection, so we don't have a whole lot of choice here
+      runner = new IndexedRunner()
       {
-        String clientToken = _getClientToken(ourClientIdPrefix, currClientId);
-        
-        if (clientToken != null)
+        @Override
+        protected void process(UIComponent kid, ComponentProcessingContext cpContext)
         {
-          rowsToVisit.add(clientToken);          
+          if (kid.getChildCount() > 0)
+          {
+            for (UIComponent grandKid : kid.getChildren())
+            {
+              if (UIXComponent.visitTree(noColumnFacetContext, grandKid, visitCallback))
+              {
+                throw new AbortProcessingException();
+              }
+            }
+          }
         }
-      }
+      };
     }
     else
     {
-      String clientToken = _getClientToken(ourClientIdPrefix,
-                                           subtreeIds.iterator().next());
+      // We are only visiting a subset of the tree, so figure out which rows to visit
+      
+      String ourClientIdPrefix = getClientId(visitContext.getFacesContext());
+     
+      int subtreeIdCount = subtreeIds.size();
+      
+      // build up a set of the row keys to visit rather than iterating
+      // and visiting every row
+      Set<String> rowsToVisit;
       
-      if (clientToken != null)
+      if (subtreeIdCount > 1)
       {
-        rowsToVisit = Collections.singleton(clientToken);
+        rowsToVisit = new HashSet<String>(subtreeIdCount);
+  
+        for (String currClientId : subtreeIds)
+        {
+          String clientToken = _getClientToken(ourClientIdPrefix, currClientId);
+          
+          if (clientToken != null)
+          {
+            rowsToVisit.add(clientToken);          
+          }
+        }
       }
       else
       {
-        rowsToVisit = Collections.emptySet();
+        String clientToken = _getClientToken(ourClientIdPrefix,
+                                             subtreeIds.iterator().next());
+        
+        if (clientToken != null)
+        {
+          rowsToVisit = Collections.singleton(clientToken);
+        }
+        else
+        {
+          rowsToVisit = Collections.emptySet();
+        }
       }
-    }
-    
-    // we didn't visit any data
-    if (rowsToVisit.isEmpty())
-      return false;
-    
-    // create a special VisitContext that doesn't visit the Facets
-    // of column components since they aren't visited on each row
-    final VisitContext noColumnFacetContext = new NoColumnFacetsVisitContext(visitContext);
-    
-    // visit only the rows
-    Runner runner = new KeyedRunner(rowsToVisit)
-    {
-      @Override
-      protected void process(
-        UIComponent                kid,
-        ComponentProcessingContext cpContext
-        ) throws IOException
+      
+      // we didn't visit any data
+      if (rowsToVisit.isEmpty())
+        return false;
+
+      // visit only the rows we need to
+      runner = new KeyedRunner(rowsToVisit)
       {
-        if (kid.getChildCount() > 0)
+        @Override
+        protected void process(
+          UIComponent                kid,
+          ComponentProcessingContext cpContext
+          ) throws IOException
         {
-          for (UIComponent grandKid : kid.getChildren())
+          if (kid.getChildCount() > 0)
           {
-            if (UIXComponent.visitTree(noColumnFacetContext, grandKid, visitCallback))
+            for (UIComponent grandKid : kid.getChildren())
             {
-              throw new AbortProcessingException();
+              if (UIXComponent.visitTree(noColumnFacetContext, grandKid, visitCallback))
+              {
+                throw new AbortProcessingException();
+              }
             }
           }
         }
-      }
-    };
-
+      };
+    }
+        
     try
     {
       runner.run();

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.