You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Vadim Gritsenko <va...@reverycodes.com> on 2004/01/23 22:45:35 UTC
Repeater initial size
Hi all,
Found a bug in repeater with initial size and binding: after binding,
repeater always has (amount of rows in model) + (initial size) rows.
This is due to the fact that method removeRows in addition to removing
all the rows actually adds initialSize rows to the repeater (as its
javadoc states). And then, binding adds even more rows.
So, either binding should remove all those empty rows alltogether, or it
should overwrite those empty rows with data, as per this patch:
Index:
src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java,v
retrieving revision 1.15
diff -u -r1.15 RepeaterJXPathBinding.java
---
src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java
11 Jan 2004 20:51:16 -0000
1.15
+++
src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java
23 Jan 2004 21:33:56 -0000
@@ -141,6 +141,7 @@
// Find the repeater
Repeater repeater = (Repeater) frmModel.getWidget(this.repeaterId);
repeater.removeRows();
+ int initialSize = repeater.getSize();
// build a jxpath iterator for pointers
JXPathContext repeaterContext =
jxpc.getRelativeContext(jxpc.getPointer(this.repeaterPath));
@@ -149,7 +150,12 @@
//iterate through it
while (rowPointers.hasNext()) {
// create a new row, take that as the frmModelSubContext
- Repeater.RepeaterRow thisRow = repeater.addRow();
+ Repeater.RepeaterRow thisRow;
+ if (initialSize > 0) {
+ thisRow = repeater.getRow(--initialSize);
+ } else {
+ thisRow = repeater.addRow();
+ }
// make a jxpath ObjectModelSubcontext on the iterated element
Pointer jxp = (Pointer) rowPointers.next();
If nobody screams... I'll apply it.
Vadim