myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r1803533 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/ impl/src/main/java/org/apache/myfaces/view/facelets/component/
Date Mon, 31 Jul 2017 13:20:07 GMT
Author: bommel
Date: Mon Jul 31 13:20:07 2017
New Revision: 1803533

URL: http://svn.apache.org/viewvc?rev=1803533&view=rev
Log:
MYFACES-4128
pushComponentToEL should be called before isVisitable is called in visitTree of UIData, UIForm,
UINamingContainer and UIRepeat

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UINamingContainer.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java?rev=1803533&r1=1803532&r2=1803533&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java Mon Jul 31 13:20:07
2017
@@ -2216,123 +2216,126 @@ public class UIData extends UIComponentB
     @Override
     public boolean visitTree(VisitContext context, VisitCallback callback)
     {
-        if (!isVisitable(context))
-        {
-            return false;
-        }
-
-        boolean isCachedFacesContext = isCachedFacesContext();
-        if (!isCachedFacesContext)
-        {
-            setCachedFacesContext(context.getFacesContext());
-        }
-        // save the current row index
-        int oldRowIndex = getRowIndex();
-        // set row index to -1 to process the facets and to get the rowless clientId
-        setRowIndex(-1);
         // push the Component to EL
         pushComponentToEL(context.getFacesContext(), this);
         try
         {
-            VisitResult visitResult = context.invokeVisitCallback(this,
-                    callback);
-            switch (visitResult)
+            if (!isVisitable(context))
             {
-            //we are done nothing has to be processed anymore
-            case COMPLETE:
-                return true;
-
-            case REJECT:
                 return false;
+            }
 
-                //accept
-            default:
-                // determine if we need to visit our children 
-                Collection<String> subtreeIdsToVisit = context
-                        .getSubtreeIdsToVisit(this);
-                boolean doVisitChildren = subtreeIdsToVisit != null
-                        && !subtreeIdsToVisit.isEmpty();
-                if (doVisitChildren)
+            boolean isCachedFacesContext = isCachedFacesContext();
+            if (!isCachedFacesContext)
+            {
+                setCachedFacesContext(context.getFacesContext());
+            }
+            // save the current row index
+            int oldRowIndex = getRowIndex();
+            // set row index to -1 to process the facets and to get the rowless clientId
+            setRowIndex(-1);
+            try
+            {
+                VisitResult visitResult = context.invokeVisitCallback(this,
+                        callback);
+                switch (visitResult)
                 {
-                    // visit the facets of the component
-                    if (getFacetCount() > 0)
+                //we are done nothing has to be processed anymore
+                case COMPLETE:
+                    return true;
+
+                case REJECT:
+                    return false;
+
+                    //accept
+                default:
+                    // determine if we need to visit our children
+                    Collection<String> subtreeIdsToVisit = context
+                            .getSubtreeIdsToVisit(this);
+                    boolean doVisitChildren = subtreeIdsToVisit != null
+                            && !subtreeIdsToVisit.isEmpty();
+                    if (doVisitChildren)
                     {
-                        for (UIComponent facet : getFacets().values())
+                        // visit the facets of the component
+                        if (getFacetCount() > 0)
                         {
-                            if (facet.visitTree(context, callback))
+                            for (UIComponent facet : getFacets().values())
                             {
-                                return true;
+                                if (facet.visitTree(context, callback))
+                                {
+                                    return true;
+                                }
                             }
                         }
-                    }
-                    //(Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
-                    Boolean skipIterationHint = context.getHints().contains(VisitHint.SKIP_ITERATION);
-                    if (skipIterationHint != null && skipIterationHint.booleanValue())
-                    {
-                        // If SKIP_ITERATION is enabled, do not take into account rows.
-                        for (int i = 0, childCount = getChildCount(); i < childCount;
i++ )
+                        boolean skipIterationHint = context.getHints().contains(VisitHint.SKIP_ITERATION);
+                        if (skipIterationHint)
                         {
-                            UIComponent child = getChildren().get(i);
-                            if (child.visitTree(context, callback))
+                            // If SKIP_ITERATION is enabled, do not take into account rows.
+                            for (int i = 0, childCount = getChildCount(); i < childCount;
i++ )
                             {
-                                return true;
+                                UIComponent child = getChildren().get(i);
+                                if (child.visitTree(context, callback))
+                                {
+                                    return true;
+                                }
                             }
                         }
-                    }
-                    else
-                    {
-                        // visit every column directly without visiting its children 
-                        // (the children of every UIColumn will be visited later for 
-                        // every row) and also visit the column's facets
-                        for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
+                        else
                         {
-                            UIComponent child = getChildren().get(i);
-                            if (child instanceof UIColumn)
+                            // visit every column directly without visiting its children
+                            // (the children of every UIColumn will be visited later for
+                            // every row) and also visit the column's facets
+                            for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
                             {
-                                VisitResult columnResult = context.invokeVisitCallback(child,
callback);
-                                if (columnResult == VisitResult.COMPLETE)
-                                {
-                                    return true;
-                                }
-                                if (child.getFacetCount() > 0)
+                                UIComponent child = getChildren().get(i);
+                                if (child instanceof UIColumn)
                                 {
-                                    for (UIComponent facet : child.getFacets().values())
+                                    VisitResult columnResult = context.invokeVisitCallback(child,
callback);
+                                    if (columnResult == VisitResult.COMPLETE)
+                                    {
+                                        return true;
+                                    }
+                                    if (child.getFacetCount() > 0)
                                     {
-                                        if (facet.visitTree(context, callback))
+                                        for (UIComponent facet : child.getFacets().values())
                                         {
-                                            return true;
+                                            if (facet.visitTree(context, callback))
+                                            {
+                                                return true;
+                                            }
                                         }
                                     }
                                 }
                             }
-                        }
-                        // iterate over the rows
-                        int rowsToProcess = getRows();
-                        // if getRows() returns 0, all rows have to be processed
-                        if (rowsToProcess == 0)
-                        {
-                            rowsToProcess = getRowCount();
-                        }
-                        int rowIndex = getFirst();
-                        for (int rowsProcessed = 0; rowsProcessed < rowsToProcess; rowsProcessed++,
rowIndex++)
-                        {
-                            setRowIndex(rowIndex);
-                            if (!isRowAvailable())
+                            // iterate over the rows
+                            int rowsToProcess = getRows();
+                            // if getRows() returns 0, all rows have to be processed
+                            if (rowsToProcess == 0)
                             {
-                                return false;
+                                rowsToProcess = getRowCount();
                             }
-                            // visit the children of every child of the UIData that is an
instance of UIColumn
-                            for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
+                            int rowIndex = getFirst();
+                            for (int rowsProcessed = 0; rowsProcessed < rowsToProcess;
rowsProcessed++, rowIndex++)
                             {
-                                UIComponent child = getChildren().get(i);
-                                if (child instanceof UIColumn)
+                                setRowIndex(rowIndex);
+                                if (!isRowAvailable())
+                                {
+                                    return false;
+                                }
+                                // visit the children of every child of the UIData that is
an instance of UIColumn
+                                for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
                                 {
-                                    for (int j = 0, grandChildCount = child.getChildCount();
j < grandChildCount; j++)
+                                    UIComponent child = getChildren().get(i);
+                                    if (child instanceof UIColumn)
                                     {
-                                        UIComponent grandchild = child.getChildren().get(j);
-                                        if (grandchild.visitTree(context, callback))
+                                        for (int j = 0, grandChildCount = child.getChildCount();
+                                             j < grandChildCount; j++)
                                         {
-                                            return true;
+                                            UIComponent grandchild = child.getChildren().get(j);
+                                            if (grandchild.visitTree(context, callback))
+                                            {
+                                                return true;
+                                            }
                                         }
                                     }
                                 }
@@ -2341,18 +2344,21 @@ public class UIData extends UIComponentB
                     }
                 }
             }
+            finally
+            {
+                // restore the old row index
+                setRowIndex(oldRowIndex);
+                if (!isCachedFacesContext)
+                {
+                    setCachedFacesContext(null);
+                }
+            }
         }
         finally
         {
-            // pop the component from EL and restore the old row index
+            // pop the component from EL
             popComponentFromEL(context.getFacesContext());
-            setRowIndex(oldRowIndex);
-            if (!isCachedFacesContext)
-            {
-                setCachedFacesContext(null);
-            }
         }
-
         // Return false to allow the visiting to continue
         return false;
     }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java?rev=1803533&r1=1803532&r2=1803533&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java Mon Jul 31 13:20:07
2017
@@ -295,6 +295,7 @@ public class UIForm extends UIComponentB
         }
         else
         {
+            pushComponentToEL(context.getFacesContext(), this);
             boolean isCachedFacesContext = isCachedFacesContext();
             try
             {
@@ -302,63 +303,56 @@ public class UIForm extends UIComponentB
                 {
                     setCachedFacesContext(context.getFacesContext());
                 }
-                
+
                 if (!isVisitable(context))
                 {
                     return false;
                 }
-        
-                pushComponentToEL(context.getFacesContext(), this);
-                try
+
+                VisitResult res = context.invokeVisitCallback(this, callback);
+                switch (res)
                 {
-                    VisitResult res = context.invokeVisitCallback(this, callback);
-                    switch (res)
+                //we are done nothing has to be processed anymore
+                case COMPLETE:
+                    return true;
+
+                case REJECT:
+                    return false;
+
+                //accept
+                default:
+                    // Take advantage of the fact this is a NamingContainer
+                    // and we can know if there are ids to visit inside it
+                    Collection<String> subtreeIdsToVisit = context.getSubtreeIdsToVisit(this);
+
+                    if (subtreeIdsToVisit != null && !subtreeIdsToVisit.isEmpty())
                     {
-                    //we are done nothing has to be processed anymore
-                    case COMPLETE:
-                        return true;
-        
-                    case REJECT:
-                        return false;
-        
-                    //accept
-                    default:
-                        // Take advantage of the fact this is a NamingContainer
-                        // and we can know if there are ids to visit inside it 
-                        Collection<String> subtreeIdsToVisit = context.getSubtreeIdsToVisit(this);
-                        
-                        if (subtreeIdsToVisit != null && !subtreeIdsToVisit.isEmpty())
+                        if (getFacetCount() > 0)
                         {
-                            if (getFacetCount() > 0)
+                            for (UIComponent facet : getFacets().values())
                             {
-                                for (UIComponent facet : getFacets().values())
+                                if (facet.visitTree(context, callback))
                                 {
-                                    if (facet.visitTree(context, callback))
-                                    {
-                                        return true;
-                                    }
+                                    return true;
                                 }
                             }
-                            for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
+                        }
+                        for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
+                        {
+                            UIComponent child = getChildren().get(i);
+                            if (child.visitTree(context, callback))
                             {
-                                UIComponent child = getChildren().get(i);
-                                if (child.visitTree(context, callback))
-                                {
-                                    return true;
-                                }
+                                return true;
                             }
                         }
-                        return false;
                     }
-                }
-                finally
-                {
-                    //all components must call popComponentFromEl after visiting is finished
-                    popComponentFromEL(context.getFacesContext());
+                    return false;
                 }
             }
             finally
             {
+                //all components must call popComponentFromEl after visiting is finished
+                popComponentFromEL(context.getFacesContext());
                 if (!isCachedFacesContext)
                 {
                     setCachedFacesContext(null);

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UINamingContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UINamingContainer.java?rev=1803533&r1=1803532&r2=1803533&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UINamingContainer.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UINamingContainer.java Mon
Jul 31 13:20:07 2017
@@ -136,6 +136,7 @@ public class UINamingContainer extends U
     @Override
     public boolean visitTree(VisitContext context, VisitCallback callback)
     {
+        pushComponentToEL(context.getFacesContext(), this);
         boolean isCachedFacesContext = isCachedFacesContext();
         try
         {
@@ -143,63 +144,56 @@ public class UINamingContainer extends U
             {
                 setCachedFacesContext(context.getFacesContext());
             }
-            
+
             if (!isVisitable(context))
             {
                 return false;
             }
-    
-            pushComponentToEL(context.getFacesContext(), this);
-            try
+
+            VisitResult res = context.invokeVisitCallback(this, callback);
+            switch (res)
             {
-                VisitResult res = context.invokeVisitCallback(this, callback);
-                switch (res)
-                {
-                    //we are done nothing has to be processed anymore
-                    case COMPLETE:
-                        return true;
+                //we are done nothing has to be processed anymore
+                case COMPLETE:
+                    return true;
 
-                    case REJECT:
-                        return false;
+                case REJECT:
+                    return false;
 
-                    //accept
-                    default:
-                        // Take advantage of the fact this is a NamingContainer
-                        // and we can know if there are ids to visit inside it
-                        Collection<String> subtreeIdsToVisit = context.getSubtreeIdsToVisit(this);
+                //accept
+                default:
+                    // Take advantage of the fact this is a NamingContainer
+                    // and we can know if there are ids to visit inside it
+                    Collection<String> subtreeIdsToVisit = context.getSubtreeIdsToVisit(this);
 
-                        if (subtreeIdsToVisit != null && !subtreeIdsToVisit.isEmpty())
+                    if (subtreeIdsToVisit != null && !subtreeIdsToVisit.isEmpty())
+                    {
+                        if (getFacetCount() > 0)
                         {
-                            if (getFacetCount() > 0)
+                            for (UIComponent facet : getFacets().values())
                             {
-                                for (UIComponent facet : getFacets().values())
+                                if (facet.visitTree(context, callback))
                                 {
-                                    if (facet.visitTree(context, callback))
-                                    {
-                                        return true;
-                                    }
+                                    return true;
                                 }
                             }
-                            for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
+                        }
+                        for (int i = 0, childCount = getChildCount(); i < childCount;
i++)
+                        {
+                            UIComponent child = getChildren().get(i);
+                            if (child.visitTree(context, callback))
                             {
-                                UIComponent child = getChildren().get(i);
-                                if (child.visitTree(context, callback))
-                                {
-                                    return true;
-                                }
+                                return true;
                             }
                         }
-                        return false;
-                }
-            }
-            finally
-            {
-                //all components must call popComponentFromEl after visiting is finished
-                popComponentFromEL(context.getFacesContext());
+                    }
+                    return false;
             }
         }
         finally
         {
+            //all components must call popComponentFromEl after visiting is finished
+            popComponentFromEL(context.getFacesContext());
             if (!isCachedFacesContext)
             {
                 setCachedFacesContext(null);

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java?rev=1803533&r1=1803532&r2=1803533&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
Mon Jul 31 13:20:07 2017
@@ -1119,106 +1119,109 @@ public class UIRepeat extends UIComponen
     {
         // override the behavior from UIComponent to visit
         // all children once per "row"
-        
-        //(Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
-        Boolean skipIterationHint = context.getHints().contains(VisitHint.SKIP_ITERATION);
-        if (skipIterationHint != null && skipIterationHint.booleanValue())
+
+        boolean skipIterationHint = context.getHints().contains(VisitHint.SKIP_ITERATION);
+        if (skipIterationHint)
         {
             return super.visitTree(context, callback);
         }
-        
-        if (!isVisitable(context)) 
-        {
-            return false;
-        }
-        
-        // save the current index, count aside
-        final int prevIndex = _index;
-        final int prevCount = _count;
-        
-        // validate attributes
-        _validateAttributes();
-        
-        // reset index and save scope values
-        _captureScopeValues();
-        _setIndex(-1);
-        
         // push the Component to EL
         pushComponentToEL(context.getFacesContext(), this);
-        try 
+        try
         {
-            VisitResult res = context.invokeVisitCallback(this, callback);
-            switch (res) 
+            if (!isVisitable(context))
             {
-            // we are done, nothing has to be processed anymore
-            case COMPLETE:
-                return true;
-
-            case REJECT:
                 return false;
+            }
+
+            // save the current index, count aside
+            final int prevIndex = _index;
+            final int prevCount = _count;
+
+            // validate attributes
+            _validateAttributes();
 
-            //accept
-            default:
-                // determine if we need to visit our children
-                // Note that we need to do this check because we are a NamingContainer
-                Collection<String> subtreeIdsToVisit = context
-                        .getSubtreeIdsToVisit(this);
-                boolean doVisitChildren = subtreeIdsToVisit != null
-                        && !subtreeIdsToVisit.isEmpty();
-                if (doVisitChildren)
+            // reset index and save scope values
+            _captureScopeValues();
+            _setIndex(-1);
+
+            try
+            {
+                VisitResult res = context.invokeVisitCallback(this, callback);
+                switch (res)
                 {
-                    // visit the facets of the component
-                    if (getFacetCount() > 0) 
+                // we are done, nothing has to be processed anymore
+                case COMPLETE:
+                    return true;
+
+                case REJECT:
+                    return false;
+
+                //accept
+                default:
+                    // determine if we need to visit our children
+                    // Note that we need to do this check because we are a NamingContainer
+                    Collection<String> subtreeIdsToVisit = context
+                            .getSubtreeIdsToVisit(this);
+                    boolean doVisitChildren = subtreeIdsToVisit != null
+                            && !subtreeIdsToVisit.isEmpty();
+                    if (doVisitChildren)
                     {
-                        for (UIComponent facet : getFacets().values()) 
+                        // visit the facets of the component
+                        if (getFacetCount() > 0)
                         {
-                            if (facet.visitTree(context, callback)) 
+                            for (UIComponent facet : getFacets().values())
                             {
-                                return true;
+                                if (facet.visitTree(context, callback))
+                                {
+                                    return true;
+                                }
                             }
                         }
-                    }
-                    
-                    // visit the children once per "row"
-                    if (getChildCount() > 0) 
-                    {
-                        int i = getOffset();
-                        int end = getSize();
-                        int step = getStep();
-                        end = (end >= 0) ? i + end : Integer.MAX_VALUE - 1;
-                        _count = 0;
-                        
-                        _setIndex(i);
-                        while (i < end && _isIndexAvailable())
+
+                        // visit the children once per "row"
+                        if (getChildCount() > 0)
                         {
-                            for (int j = 0, childCount = getChildCount(); j < childCount;
j++)
+                            int i = getOffset();
+                            int end = getSize();
+                            int step = getStep();
+                            end = (end >= 0) ? i + end : Integer.MAX_VALUE - 1;
+                            _count = 0;
+
+                            _setIndex(i);
+                            while (i < end && _isIndexAvailable())
                             {
-                                UIComponent child = getChildren().get(j);
-                                if (child.visitTree(context, callback)) 
+                                for (int j = 0, childCount = getChildCount(); j < childCount;
j++)
                                 {
-                                    return true;
+                                    UIComponent child = getChildren().get(j);
+                                    if (child.visitTree(context, callback))
+                                    {
+                                        return true;
+                                    }
                                 }
+
+                                _count++;
+                                i += step;
+
+                                _setIndex(i);
                             }
-                            
-                            _count++;
-                            i += step;
-                            
-                            _setIndex(i);
                         }
                     }
+                    return false;
                 }
-                return false;
+            }
+            finally
+            {
+                // restore the previous count, index and scope values
+                _count = prevCount;
+                _setIndex(prevIndex);
+                _restoreScopeValues();
             }
         }
-        finally 
+        finally
         {
             // pop the component from EL
             popComponentFromEL(context.getFacesContext());
-            
-            // restore the previous count, index and scope values
-            _count = prevCount;
-            _setIndex(prevIndex);
-            _restoreScopeValues();
         }
     }
 



Mime
View raw message