You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2003/11/04 00:01:41 UTC

cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel Repeater.java RepeaterDefinition.java

sylvain     2003/11/03 15:01:41

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/formmodel
                        Repeater.java RepeaterDefinition.java
  Log:
  Ensure a repeater has it's initial size also on removeRows (should be renamed "reset" ?)
  
  Revision  Changes    Path
  1.13      +8 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Repeater.java
  
  Index: Repeater.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Repeater.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Repeater.java	3 Nov 2003 17:05:32 -0000	1.12
  +++ Repeater.java	3 Nov 2003 23:01:41 -0000	1.13
  @@ -76,6 +76,8 @@
   
       public Repeater(RepeaterDefinition repeaterDefinition) {
           this.definition = repeaterDefinition;
  +        // setup initial size
  +        removeRows();
       }
   
       public String getId() {
  @@ -163,10 +165,15 @@
       }
   
       /**
  -     * Clears all rows from the repeater.
  +     * Clears all rows from the repeater and go back to the initial size
        */
       public void removeRows() {
           rows.clear();
  +        
  +        // and reset to initial size
  +        for (int i = 0; i < this.definition.getInitialSize(); i++) {
  +            addRow();
  +        }
       }
   
       /**
  
  
  
  1.3       +5 -5      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/RepeaterDefinition.java
  
  Index: RepeaterDefinition.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/RepeaterDefinition.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RepeaterDefinition.java	3 Nov 2003 17:05:32 -0000	1.2
  +++ RepeaterDefinition.java	3 Nov 2003 23:01:41 -0000	1.3
  @@ -80,10 +80,10 @@
       }
   
       public Widget createInstance() {
  -        Repeater result = new Repeater(this);
  -        for (int i = 0; i < this.initialSize; i++) {
  -            result.addRow();
  -        }
  -        return result;
  +        return new Repeater(this);
  +    }
  +    
  +    public int getInitialSize() {
  +        return this.initialSize;
       }
   }