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 2011/11/04 18:29:50 UTC

svn commit: r1197679 - in /myfaces/trinidad/branches/ar_1940: trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ trinidad-examples/trinidad-demo/src/main/java/org/apache/myfa...

Author: arobinson74
Date: Fri Nov  4 17:29:49 2011
New Revision: 1197679

URL: http://svn.apache.org/viewvc?rev=1197679&view=rev
Log:
Merge of changes from the old branch

Modified:
    myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java
    myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TagComponentBridge.java
    myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
    myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java
    myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx

Modified: myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java?rev=1197679&r1=1197678&r2=1197679&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java (original)
+++ myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java Fri Nov  4 17:29:49 2011
@@ -6,9 +6,9 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,11 +18,12 @@
  */
 package org.apache.myfaces.trinidad.component;
 
-import javax.faces.component.UIComponent;
-
-import java.util.Collection;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+
+import javax.faces.component.UIComponent;
+
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
 
@@ -54,23 +55,23 @@ class ChildArrayList extends ArrayList<U
       // Only adjust the index when the child is re-added to the same parent
       if (oldParent == _parent)
       {
-        index = adjustedIndex; 
+        index = adjustedIndex;
       }
     }
-    
+
     // do not change the order of these calls, see TRINIDAD-1674 for more info
     super.add(index, element);
     element.setParent(_parent);
   }
 
-  
+
   @Override
   public boolean add(UIComponent element)
   {
     add(size(), element);
     return true;
   }
-  
+
   @Override
   public boolean addAll(Collection<? extends UIComponent> collection)
   {
@@ -79,7 +80,7 @@ class ChildArrayList extends ArrayList<U
 
   @Override
   public boolean addAll(
-      int index, 
+      int index,
       Collection<? extends UIComponent> collection)
   {
     boolean changed = false;
@@ -91,7 +92,7 @@ class ChildArrayList extends ArrayList<U
       add(index++, element);
       changed = true;
     }
-    
+
     return changed;
   }
 
@@ -109,10 +110,10 @@ class ChildArrayList extends ArrayList<U
   {
     if (element == null)
       throw new NullPointerException();
-    
+
     if (!(element instanceof UIComponent))
       return false;
-  
+
     if (super.remove(element))
     {
       UIComponent child = (UIComponent) element;
@@ -127,26 +128,26 @@ class ChildArrayList extends ArrayList<U
   public void clear()
   {
     int size = this.size();
-    
+
     while ( size > 0)
     {
       size--;
       remove(size);
     }
-    
+
     super.clear();
   }
-  
+
   @Override
   public boolean removeAll(Collection<?> collection)
   {
     boolean result = false;
-    for(Object element : collection)
+    for (Object element : collection)
     {
       if (remove(element))
         result = true;
     }
-    
+
     return result;
   }
 
@@ -155,7 +156,7 @@ class ChildArrayList extends ArrayList<U
   {
     if (element == null)
       throw new NullPointerException();
-    
+
     if ((index < 0) || (index >= size()))
       throw new IndexOutOfBoundsException();
 
@@ -163,10 +164,10 @@ class ChildArrayList extends ArrayList<U
     UIComponent previous = get(index);
 
     previous.setParent(null);
-    
+
     child.setParent(_parent);
     super.set(index, element);
-    
+
     return previous;
   }
 
@@ -193,7 +194,7 @@ class ChildArrayList extends ArrayList<U
         }
       }
     }
-    
+
     Collection<UIComponent> facets = parent.getFacets().values();
     if (facets.contains(component))
     {
@@ -207,7 +208,6 @@ class ChildArrayList extends ArrayList<U
     return index;
   }
 
-
   private final UIComponent _parent;
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(
     ChildArrayList.class);

Modified: myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TagComponentBridge.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TagComponentBridge.java?rev=1197679&r1=1197678&r2=1197679&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TagComponentBridge.java (original)
+++ myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TagComponentBridge.java Fri Nov  4 17:29:49 2011
@@ -68,6 +68,7 @@ final class TagComponentBridge
   void notifyComponentProcessed(
     UIComponent component)
   {
+    System.out.println("Component processed: " + component.getClientId());
     for (TrinidadIterationTag tag : _tags)
     {
       tag.childComponentProcessed(component);
@@ -83,6 +84,7 @@ final class TagComponentBridge
   void notifyAfterComponentProcessed(
     UIComponent component)
   {
+    System.out.println("After component processed: " + component.getClientId());
     for (TrinidadIterationTag tag : _tags)
     {
       tag.afterChildComponentProcessed(component);

Modified: myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java?rev=1197679&r1=1197678&r2=1197679&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java (original)
+++ myfaces/trinidad/branches/ar_1940/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java Fri Nov  4 17:29:49 2011
@@ -37,13 +37,17 @@ import javax.el.ValueExpression;
 import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
 import javax.faces.webapp.UIComponentELTag;
 
 import javax.servlet.jsp.JspException;
 
 import org.apache.myfaces.trinidad.bean.FacesBean;
 import org.apache.myfaces.trinidad.bean.PropertyKey;
+import org.apache.myfaces.trinidad.change.ChangeManager;
 import org.apache.myfaces.trinidad.component.UIXComponent;
+import org.apache.myfaces.trinidad.component.UIXDocument;
 import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
@@ -101,7 +105,7 @@ abstract public class UIXComponentELTag 
       {
         ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
         // Used by SessionChangeManager to confirm that the state was not restored.
-        ec.getRequestMap().put(DOCUMENT_CREATED_KEY, Boolean.TRUE);
+        ec.getRequestMap().put(_DOCUMENT_CREATED_KEY, Boolean.TRUE);
       }
       ChangeManager cm = RequestContext.getCurrentInstance().getChangeManager();
       cm.applyComponentChangesForCurrentView(FacesContext.getCurrentInstance());

Modified: myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java?rev=1197679&r1=1197678&r2=1197679&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java (original)
+++ myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java Fri Nov  4 17:29:49 2011
@@ -9,12 +9,12 @@ import java.util.List;
 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.FacesContext;
 import javax.faces.event.ActionEvent;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.trinidad.change.ChangeManager;
 import org.apache.myfaces.trinidad.change.ReorderChildrenComponentChange;
 import org.apache.myfaces.trinidad.component.UIXCommand;
 import org.apache.myfaces.trinidad.component.visit.VisitTreeUtils;
@@ -52,6 +52,12 @@ public class ForEachBean
       return _lastName;
     }
 
+    @Override
+    public String toString()
+    {
+      return ("Person[(" + _key + ") " + _lastName + ", " + _firstName + "]");
+    }
+
     private final String _key;
     private final String _firstName;
     private final String _lastName;
@@ -120,6 +126,7 @@ public class ForEachBean
     {
       Person person = (Person)_model.getRowData();
       orderedKeys.add(person.getKey());
+      System.out.println("Person: " + person);
     }
     _model.setRowKey(origRowKey);
 
@@ -127,6 +134,7 @@ public class ForEachBean
          RequestContext.getCurrentInstance().getPartialTargets(sourceComponent))
     {
       String clientId = targetComponent.getClientId();
+      System.out.println("CLIENT ID: " + clientId);
       VisitTreeUtils.visitSingleComponent(facesContext, clientId,
         new ReorderChildrenVisitCallback(orderedKeys));
     }
@@ -151,16 +159,25 @@ public class ForEachBean
       VisitContext visitContext,
       UIComponent  target)
     {
+      System.out.println("**************VISIT " + target.getClientId());
       FacesContext facesContext = visitContext.getFacesContext();
-      List<String> childrenClientIds = new ArrayList<String>();
-      VisitContext childrenContext = VisitTreeUtils.createVisitContext(facesContext,
-                                       null,
-                                       Collections.singleton(VisitHint.SKIP_UNRENDERED));
-      target.visitTree(childrenContext, new GetChildrenClientIdsVisitCallback(childrenClientIds));
-
-      Collections.sort(childrenClientIds, this);
-
-      (new ReorderChildrenComponentChange(childrenClientIds)).changeComponent(target);
+      List<String> childrenIds = new ArrayList<String>();
+      for (UIComponent child : target.getChildren())
+      {
+        // Safe to call get ID out of context
+        childrenIds.add(child.getId());
+      }
+
+      Collections.sort(childrenIds, this);
+      System.out.println("Sorted list:");
+      for (String clientId : childrenIds)
+      {
+        System.out.println("  " + clientId);
+      }
+
+      ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
+      apm.addComponentChange(facesContext, target,
+        new ReorderChildrenComponentChange(childrenIds));
 
       return VisitResult.COMPLETE;
     }
@@ -182,27 +199,6 @@ public class ForEachBean
     private final List<String> _orderedKeys;
   }
 
-  private static class GetChildrenClientIdsVisitCallback
-    implements VisitCallback
-  {
-    private GetChildrenClientIdsVisitCallback(
-      List<String> clientIds)
-    {
-      this._clientIds = clientIds;
-    }
-
-    @Override
-    public VisitResult visit(
-      VisitContext visitContext,
-      UIComponent  target)
-    {
-      _clientIds.add(target.getClientId(visitContext.getFacesContext()));
-      return VisitResult.REJECT;
-    }
-
-    private final List<String> _clientIds;
-  }
-
   private final List<String> _simpleList;
   private final SortableModel _model;
   private String _sortProperty;

Modified: myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx?rev=1197679&r1=1197678&r2=1197679&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx (original)
+++ myfaces/trinidad/branches/ar_1940/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx Fri Nov  4 17:29:49 2011
@@ -82,7 +82,8 @@
             </tr:panelHeader>
             <tr:panelHeader text="Reorder example with CollectionModel">
               <tr:panelGroupLayout layout="vertical">
-                <tr:panelGroupLayout layout="vertical" id="personForEachParent">
+                <tr:panelGroupLayout layout="vertical" id="personForEachParent"
+                                     partialTriggers="applySort">
                   <tr:forEach var="person" items="#{forEachBean.model}" varStatus="vs">
                     <tr:panelGroupLayout id="personPgl">
                       <f:facet name="separator">
@@ -94,7 +95,7 @@
                                      value="Last name: #{person.lastName}"/>
                       <tr:outputText value="(Panel group layout client ID: #{component.parent.clientId})"/>
                     </tr:panelGroupLayout>
-                    <tr:separator rendered="#{not vs.last}" />
+                    <tr:separator id="sep1" rendered="#{not vs.last}" />
                   </tr:forEach>
                 </tr:panelGroupLayout>
               </tr:panelGroupLayout>
@@ -109,7 +110,7 @@
                   <tr:selectItem label="Descending" value="#{false}" />
                 </tr:selectOneRadio>
                 <f:facet name="footer">
-                  <tr:commandLink partialTriggers="personForEachParent"
+                  <tr:commandLink id="applySort"
                                   text="Apply sort"
                                   partialSubmit="true"
                                   actionListener="#{forEachBean.updateSortOrder}"/>