You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2017/01/19 00:51:12 UTC

svn commit: r1779405 - in /myfaces/core/branches/2.3.x/impl/src: main/java/org/apache/myfaces/view/facelets/tag/composite/AttachedObjectTargetImpl.java test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java

Author: lu4242
Date: Thu Jan 19 00:51:12 2017
New Revision: 1779405

URL: http://svn.apache.org/viewvc?rev=1779405&view=rev
Log:
MYFACES-4075 SearchExpression API (rollback AttachedObjectTargetImpl because possible conflict with composite components algorithm)

Modified:
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/AttachedObjectTargetImpl.java
    myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/AttachedObjectTargetImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/AttachedObjectTargetImpl.java?rev=1779405&r1=1779404&r2=1779405&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/AttachedObjectTargetImpl.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/AttachedObjectTargetImpl.java Thu Jan 19 00:51:12 2017
@@ -21,14 +21,9 @@ package org.apache.myfaces.view.facelets
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.EnumSet;
 import java.util.List;
-import java.util.Set;
 import javax.el.ValueExpression;
-import javax.faces.component.ContextCallback;
 import javax.faces.component.UIComponent;
-import javax.faces.component.search.SearchExpressionContext;
-import javax.faces.component.search.SearchExpressionHint;
 import javax.faces.context.FacesContext;
 import javax.faces.view.AttachedObjectTarget;
 import org.apache.myfaces.shared.util.StringUtils;
@@ -63,9 +58,6 @@ public class AttachedObjectTargetImpl im
         return null;
     }
 
-    private static final Set<SearchExpressionHint> EXPRESSION_HINTS =
-            EnumSet.of(SearchExpressionHint.SKIP_VIRTUAL_COMPONENTS);
-    
     @Override
     public List<UIComponent> getTargets(UIComponent topLevelComponent)
     {
@@ -74,18 +66,32 @@ public class AttachedObjectTargetImpl im
         
         if (targetsArray.length > 0)
         {
+            List<UIComponent> targetsList = new ArrayList<UIComponent>(targetsArray.length);
+            final char separatorChar = facesContext.getNamingContainerSeparatorChar();
             UIComponent facetBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
-            
-            SearchExpressionContext searchContext = SearchExpressionContext.createSearchExpressionContext(
-                                facesContext, facetBase, EXPRESSION_HINTS, null);
-            
-            CollectComponentListCallback callback = new CollectComponentListCallback(targetsArray.length);
             for (String target : targetsArray)
             {
-                facesContext.getApplication().getSearchExpressionHandler()
-                        .resolveComponents(searchContext, target, callback);
+                //UIComponent innerComponent = topLevelComponent.findComponent(
+                //        topLevelComponent.getId() + UINamingContainer.getSeparatorChar(facesContext) + target);
+                int separator = target.indexOf(separatorChar);
+                UIComponent innerComponent = null;
+                if (separator == -1)
+                {
+                    innerComponent = ComponentSupport.findComponentChildOrFacetFrom(
+                            facetBase, target, null);
+                }
+                else
+                {
+                    innerComponent = ComponentSupport.findComponentChildOrFacetFrom(
+                            facetBase, target.substring(0,separator), target);
+                }
+                
+                if (innerComponent != null)
+                {
+                    targetsList.add(innerComponent);
+                }
             }
-            return callback.getList();
+            return targetsList;
         }
         else
         {
@@ -96,6 +102,8 @@ public class AttachedObjectTargetImpl im
             String name = getName();
             if (name != null)
             {
+                //UIComponent innerComponent = topLevelComponent.findComponent(
+                //        topLevelComponent.getId() + UINamingContainer.getSeparatorChar(facesContext) + getName());
                 UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(
                         topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME),
                         name, null);
@@ -128,28 +136,4 @@ public class AttachedObjectTargetImpl im
     {
         _targets = ve;
     }
-    
-    private static class CollectComponentListCallback implements ContextCallback
-    {
-        private List<UIComponent> list = null;
-
-        public CollectComponentListCallback(int size)
-        {
-            list = new ArrayList<UIComponent>(size);
-        }
-
-        @Override
-        public void invokeContextCallback(FacesContext context, UIComponent target)
-        {
-            getList().add(target);
-        }
-
-        /**
-         * @return the list
-         */
-        public List<UIComponent> getList()
-        {
-            return list;
-        }
-    }
 }

Modified: myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java?rev=1779405&r1=1779404&r2=1779405&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java Thu Jan 19 00:51:12 2017
@@ -371,6 +371,7 @@ public class SearchExpressionImplTest ex
         Assert.assertFalse(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form:@child(0)"));
     }
 
+    /*
     @Test
     public void testCompositeComponentExpression() throws Exception
     {
@@ -380,5 +381,5 @@ public class SearchExpressionImplTest ex
         executeBuildViewCycle();
         
         
-    }
+    }*/
 }