cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <va...@reverycodes.com>
Subject Repeater initial size
Date Fri, 23 Jan 2004 21:45:35 GMT
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


Mime
View raw message