You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2017/07/31 13:31:46 UTC
svn commit: r1803537 - in /myfaces/core/branches/2.0.x:
api/src/main/java/javax/faces/component/
impl/src/main/java/org/apache/myfaces/view/facelets/component/
Author: bommel
Date: Mon Jul 31 13:31:46 2017
New Revision: 1803537
URL: http://svn.apache.org/viewvc?rev=1803537&view=rev
Log:
MYFACES-4128
pushComponentToEL should be called before isVisitable is called in visitTree of UIData, UIForm, UINamingContainer and UIRepeat
Modified:
myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java
myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIForm.java
myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UINamingContainer.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java?rev=1803537&r1=1803536&r2=1803537&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java Mon Jul 31 13:31:46 2017
@@ -1554,122 +1554,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 skipIterationHint = (Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
- 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 = (Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
+ if (skipIterationHint != null && skipIterationHint.booleanValue())
{
- 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)
{
- if (facet.visitTree(context, callback))
+ return true;
+ }
+ if (child.getFacetCount() > 0)
+ {
+ 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())
{
- for (int j = 0, grandChildCount = child.getChildCount(); j < grandChildCount; j++)
+ 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++)
+ {
+ 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;
+ }
}
}
}
@@ -1678,16 +1682,20 @@ 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
Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIForm.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIForm.java?rev=1803537&r1=1803536&r2=1803537&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIForm.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIForm.java Mon Jul 31 13:31:46 2017
@@ -306,6 +306,7 @@ public class UIForm extends UIComponentB
}
else
{
+ pushComponentToEL(context.getFacesContext(), this);
boolean isCachedFacesContext = isCachedFacesContext();
try
{
@@ -313,63 +314,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/branches/2.0.x/api/src/main/java/javax/faces/component/UINamingContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UINamingContainer.java?rev=1803537&r1=1803536&r2=1803537&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UINamingContainer.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UINamingContainer.java Mon Jul 31 13:31:46 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/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java?rev=1803537&r1=1803536&r2=1803537&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java Mon Jul 31 13:31:46 2017
@@ -1111,99 +1111,103 @@ public class UIRepeat extends UIComponen
{
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();
}
}