You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/09/09 11:14:53 UTC
cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding RepeaterJXPathBinding.java
bruno 2003/09/09 02:14:52
Modified: src/blocks/woody/java/org/apache/cocoon/woody/binding
RepeaterJXPathBinding.java
Log:
Fixed problem with deleting rows, reported by Hugo Burm.
Revision Changes Path
1.6 +14 -6 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java
Index: RepeaterJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RepeaterJXPathBinding.java 26 Aug 2003 13:55:46 -0000 1.5
+++ RepeaterJXPathBinding.java 9 Sep 2003 09:14:52 -0000 1.6
@@ -185,6 +185,7 @@
//again iterate nodes for deletion
Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
+ List rowsToDelete = new ArrayList();
while (rowPointers.hasNext()) {
Pointer jxp = (Pointer) rowPointers.next();
JXPathContext rowContext = repeaterContext.getRelativeContext(jxp);
@@ -193,12 +194,19 @@
// check if matchPath was in list of updates, if not --> bind for delete
if (!updatedRowIds.contains(matchId)) {
- if (this.deleteRowBinding != null) {
- this.deleteRowBinding.saveFormToModel(frmModel, rowContext);
- } else {
- getLogger().warn("RepeaterBinding has detected rows to delete, " +
- "but misses the <on-delete-row> binding to do it.");
- }
+ rowsToDelete.add(rowContext);
+ }
+ }
+
+ if (rowsToDelete.size() > 0) {
+ if (this.deleteRowBinding == null) {
+ getLogger().warn("RepeaterBinding has detected rows to delete, " +
+ "but misses the <on-delete-row> binding to do it.");
+ }
+ else {
+ // run backwards through the list, so that we don't get into trouble by shifting indexes
+ for (int i = rowsToDelete.size() - 1; i >= 0; i--)
+ this.deleteRowBinding.saveFormToModel(frmModel, rowsToDelete.get(i));
}
}