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/03/17 20:52:45 UTC
svn commit: r1082664 - in
/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces:
component/html/ext/AbstractHtmlDataTable.java
custom/datalist/AbstractHtmlDataList.java custom/tree2/UITreeData.java
Author: lu4242
Date: Thu Mar 17 19:52:45 2011
New Revision: 1082664
URL: http://svn.apache.org/viewvc?rev=1082664&view=rev
Log:
TOMAHAWK-1570 CLONE - Support SKIP_ITERATION FacesContext property
Modified:
myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datalist/AbstractHtmlDataList.java
myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java?rev=1082664&r1=1082663&r2=1082664&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java Thu Mar 17 19:52:45 2011
@@ -103,6 +103,7 @@ public abstract class AbstractHtmlDataTa
private static final String DEFAULT_NEWSPAPER_ORIENTATION = "vertical";
private static final String DEFAULT_DETAILSTAMP_LOCATION = "after";
+ private static final String SKIP_ITERATION_HINT = "javax.faces.visit.SKIP_ITERATION";
/**
* the property names
*/
@@ -436,83 +437,98 @@ public abstract class AbstractHtmlDataTa
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())
+ Boolean skipIterationHint = (Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
+ if (skipIterationHint != null && skipIterationHint.booleanValue())
{
- if (child instanceof UIColumn)
- {
- VisitResult columnResult = context.invokeVisitCallback(child, callback);
- if (columnResult == VisitResult.COMPLETE)
- {
- return true;
- }
- for (UIComponent facet : child.getFacets().values())
- {
- if (facet.visitTree(context, callback))
- {
+ // 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;
}
}
}
}
- boolean visitDetailStamp = (getFacet(DETAIL_STAMP_FACET_NAME) != null);
- boolean visitDetailStampRow = (getFacet(DETAIL_STAMP_ROW_FACET_NAME) != null);
- boolean visitTableRow = (getFacet(TABLE_ROW_FACET_NAME) != null);
-
- // 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;
}
}
}
}
- if (visitDetailStampRow)
+ boolean visitDetailStamp = (getFacet(DETAIL_STAMP_FACET_NAME) != null);
+ boolean visitDetailStampRow = (getFacet(DETAIL_STAMP_ROW_FACET_NAME) != null);
+ boolean visitTableRow = (getFacet(TABLE_ROW_FACET_NAME) != null);
+
+ // iterate over the rows
+ int rowsToProcess = getRows();
+ // if getRows() returns 0, all rows have to be processed
+ if (rowsToProcess == 0)
{
- UIComponent detailStampRowFacet = getFacet(DETAIL_STAMP_ROW_FACET_NAME);
- if (detailStampRowFacet.visitTree(context, callback))
- {
- return true;
- }
+ rowsToProcess = getRowCount();
}
- if (visitDetailStamp)
+ int rowIndex = getFirst();
+ for (int rowsProcessed = 0; rowsProcessed < rowsToProcess; rowsProcessed++, rowIndex++)
{
- UIComponent detailStampFacet = getFacet(DETAIL_STAMP_FACET_NAME);
- if (detailStampFacet.visitTree(context, callback))
+ setRowIndex(rowIndex);
+ if (!isRowAvailable())
{
- return true;
+ return false;
}
- }
- if (visitTableRow)
- {
- UIComponent tableRowFacet = getFacet(TABLE_ROW_FACET_NAME);
- if (tableRowFacet.visitTree(context, callback))
+ // 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;
+ }
+ }
+ }
+ }
+ if (visitDetailStampRow)
+ {
+ UIComponent detailStampRowFacet = getFacet(DETAIL_STAMP_ROW_FACET_NAME);
+ if (detailStampRowFacet.visitTree(context, callback))
+ {
+ return true;
+ }
+ }
+ if (visitDetailStamp)
+ {
+ UIComponent detailStampFacet = getFacet(DETAIL_STAMP_FACET_NAME);
+ if (detailStampFacet.visitTree(context, callback))
+ {
+ return true;
+ }
+ }
+ if (visitTableRow)
{
- return true;
+ UIComponent tableRowFacet = getFacet(TABLE_ROW_FACET_NAME);
+ if (tableRowFacet.visitTree(context, callback))
+ {
+ return true;
+ }
}
}
}
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datalist/AbstractHtmlDataList.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datalist/AbstractHtmlDataList.java?rev=1082664&r1=1082663&r2=1082664&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datalist/AbstractHtmlDataList.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datalist/AbstractHtmlDataList.java Thu Mar 17 19:52:45 2011
@@ -62,6 +62,7 @@ public abstract class AbstractHtmlDataLi
private static final int PROCESS_DECODES = 1;
private static final int PROCESS_VALIDATORS = 2; // not currently in use
private static final int PROCESS_UPDATES = 3; // not currently in use
+ private static final String SKIP_ITERATION_HINT = "javax.faces.visit.SKIP_ITERATION";
private transient FacesContext _facesContext;
@@ -416,27 +417,42 @@ public abstract class AbstractHtmlDataLi
return true;
}
}
- // iterate over the rows
- int rowsToProcess = getRows();
- // if getRows() returns 0, all rows have to be processed
- if (rowsToProcess == 0)
+ Boolean skipIterationHint = (Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
+ if (skipIterationHint != null && skipIterationHint.booleanValue())
{
- rowsToProcess = getRowCount();
+ // 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;
+ }
+ }
+ }
}
- int rowIndex = getFirst();
- for (int rowsProcessed = 0; rowsProcessed < rowsToProcess; rowsProcessed++, rowIndex++)
+ else
{
- 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 (UIComponent child : getChildren())
+ int rowIndex = getFirst();
+ for (int rowsProcessed = 0; rowsProcessed < rowsToProcess; rowsProcessed++, rowIndex++)
{
- if (child.visitTree(context, callback))
+ 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())
{
- return true;
+ if (child.visitTree(context, callback))
+ {
+ return true;
+ }
}
}
}
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java?rev=1082664&r1=1082663&r2=1082664&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java Thu Mar 17 19:52:45 2011
@@ -88,6 +88,8 @@ public class UITreeData extends UICompon
private TreeState _restoredState = null;
private transient FacesContext _facesContext;
+
+ private static final String SKIP_ITERATION_HINT = "javax.faces.visit.SKIP_ITERATION";
/**
* Constructor
@@ -561,26 +563,41 @@ public class UITreeData extends UICompon
&& !subtreeIdsToVisit.isEmpty();
if (doVisitChildren)
{
- TreeWalker walker = getDataModel().getTreeWalker();
- UIComponent facet = null;
- walker.reset();
- walker.setTree(this);
-
- while(walker.next())
+ Boolean skipIterationHint = (Boolean) context.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT);
+ if (skipIterationHint != null && skipIterationHint.booleanValue())
{
- TreeNode node = getNode();
- facet = getFacet(node.getType());
-
- if (facet == null)
- {
- log.warn("Unable to locate facet with the name: " + node.getType());
- continue;
- //throw new IllegalArgumentException("Unable to locate facet with the name: " + node.getType());
+ // 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;
+ }
+ }
}
-
- if (facet.visitTree(context, callback))
+ }
+ else
+ {
+ TreeWalker walker = getDataModel().getTreeWalker();
+ UIComponent facet = null;
+ walker.reset();
+ walker.setTree(this);
+
+ while(walker.next())
{
- return true;
+ TreeNode node = getNode();
+ facet = getFacet(node.getType());
+
+ if (facet == null)
+ {
+ log.warn("Unable to locate facet with the name: " + node.getType());
+ continue;
+ //throw new IllegalArgumentException("Unable to locate facet with the name: " + node.getType());
+ }
+
+ if (facet.visitTree(context, callback))
+ {
+ return true;
+ }
}
}
}