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 2011/02/08 23:43:31 UTC
svn commit: r1068653 - in /myfaces/core/trunk:
api/src/main/java/javax/faces/component/UIData.java
impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
Author: lu4242
Date: Tue Feb 8 22:43:31 2011
New Revision: 1068653
URL: http://svn.apache.org/viewvc?rev=1068653&view=rev
Log:
MYFACES-3036 Support SKIP_ITERATION FacesContext property
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.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=1068653&r1=1068652&r2=1068653&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 Tue Feb 8 22:43:31 2011
@@ -125,6 +125,7 @@ public class UIData extends UIComponentB
private static final int PROCESS_DECODES = 1;
private static final int PROCESS_VALIDATORS = 2;
private static final int PROCESS_UPDATES = 3;
+ private static final String SKIP_ITERATION_HINT = "javax.faces.visit.SKIP_ITERATION";
private int _rowIndex = -1;
@@ -1282,64 +1283,82 @@ public class UIData extends UIComponentB
if (doVisitChildren)
{
// visit the facets of the component
- for (UIComponent facet : getFacets().values())
+ if (getFacetCount() > 0)
{
- if (facet.visitTree(context, callback))
+ for (UIComponent facet : getFacets().values())
{
- return true;
- }
- }
- // 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 (UIComponent child : getChildren())
- {
- if (child instanceof UIColumn)
- {
- VisitResult columnResult = context.invokeVisitCallback(child, callback);
- if (columnResult == VisitResult.COMPLETE)
+ if (facet.visitTree(context, callback))
{
return true;
}
- for (UIComponent facet : child.getFacets().values())
- {
- if (facet.visitTree(context, callback))
- {
+ }
+ }
+ 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.
+ if (getChildCount() > 0) {
+ for (UIComponent child : getChildren()) {
+ if (child.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++)
+ else
{
- setRowIndex(rowIndex);
- if (!isRowAvailable())
- {
- return false;
- }
- // visit the children of every child of the UIData that is an instance of 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 (UIComponent child : getChildren())
{
if (child instanceof UIColumn)
{
- for (UIComponent grandchild : child
- .getChildren())
+ VisitResult columnResult = context.invokeVisitCallback(child, callback);
+ if (columnResult == VisitResult.COMPLETE)
{
- if (grandchild.visitTree(context, callback))
+ return true;
+ }
+ for (UIComponent facet : child.getFacets().values())
+ {
+ 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())
+ {
+ return false;
+ }
+ // visit the children of every child of the UIData that is an instance of UIColumn
+ for (UIComponent child : getChildren())
+ {
+ if (child instanceof UIColumn)
+ {
+ for (UIComponent grandchild : child
+ .getChildren())
+ {
+ if (grandchild.visitTree(context, callback))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
}
}
}
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=1068653&r1=1068652&r2=1068653&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 Tue Feb 8 22:43:31 2011
@@ -65,6 +65,8 @@ public class UIRepeat extends UIComponen
public static final String COMPONENT_TYPE = "facelets.ui.Repeat";
public static final String COMPONENT_FAMILY = "facelets";
+
+ private static final String SKIP_ITERATION_HINT = "javax.faces.visit.SKIP_ITERATION";
private final static DataModel<?> EMPTY_MODEL = new ListDataModel<Object>(Collections.emptyList());
@@ -742,6 +744,12 @@ public class UIRepeat extends UIComponen
// override the behavior from UIComponent to visit
// all children once per "row"
+ Boolean skipIterationHint = (Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
+ if (skipIterationHint != null && skipIterationHint.booleanValue())
+ {
+ return super.visitTree(context, callback);
+ }
+
if (!isVisitable(context))
{
return false;