diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java index 8ec9795bba..3cd4602c58 100644 --- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java +++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java @@ -593,27 +593,24 @@ public boolean visitTree(final VisitContext context, final VisitCallback callbac } } } - Set rowsToVisit = getRowsToVisit(context); - if (rowsToVisit.isEmpty()) { - return false; - } - // iterate over the rows to visit - for (Integer rowIndex : rowsToVisit) { - setRowIndex(rowIndex); - if (!isRowAvailable()) { - return false; + if (VisitContext.ALL_IDS == subtreeIdsToVisit) { + // iterate over all rows + int rowsToProcess = getRows(); + // if getRows() returns 0, all rows have to be processed + if (rowsToProcess == 0) { + 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++) { - final UIComponent child = getChildren().get(i); - if (child instanceof UIColumn) { - if (child instanceof AbstractUIRow) { - if (child.visitTree(context, callback)) { - return true; - } - } else { - for (int j = 0, grandChildCount = child.getChildCount(); - j < grandChildCount; j++) { + 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 (int i = 0, childCount = getChildCount(); i < childCount; i++) { + UIComponent child = getChildren().get(i); + if (child instanceof UIColumn) { + for (int j = 0, grandChildCount = child.getChildCount(); j < grandChildCount; j++) { UIComponent grandchild = child.getChildren().get(j); if (grandchild.visitTree(context, callback)) { return true; @@ -622,6 +619,36 @@ public boolean visitTree(final VisitContext context, final VisitCallback callbac } } } + } else { + Set rowsToVisit = getRowsToVisit(facesContext, subtreeIdsToVisit); + if (rowsToVisit.isEmpty()) { + return false; + } + // iterate over the rows to visit + for (Integer rowIndex : rowsToVisit) { + 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++) { + final UIComponent child = getChildren().get(i); + if (child instanceof UIColumn) { + if (child instanceof AbstractUIRow) { + if (child.visitTree(context, callback)) { + return true; + } + } else { + for (int j = 0, grandChildCount = child.getChildCount(); j < grandChildCount; j++) { + UIComponent grandchild = child.getChildren().get(j); + if (grandchild.visitTree(context, callback)) { + return true; + } + } + } + } + } + } } } } @@ -634,13 +661,12 @@ public boolean visitTree(final VisitContext context, final VisitCallback callbac return false; } - private Set getRowsToVisit(final VisitContext context) { + private Set getRowsToVisit(final FacesContext facesContext, + Collection subtreeIdsToVisit) { Set rowsToVisit = new HashSet<>(); - FacesContext facesContext = context.getFacesContext(); String clientId = getClientId(facesContext); int clientIdLengthPlusOne = clientId.length() + 1; char separatorChar = UINamingContainer.getSeparatorChar(facesContext); - Collection subtreeIdsToVisit = context.getSubtreeIdsToVisit(this); for (String subtreeId : subtreeIdsToVisit) { int rowIndex = getRowIndexFromSubtreeId(subtreeId, separatorChar, clientIdLengthPlusOne); if (rowIndex != -1) {