cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel Field.java Union.java
Date Wed, 14 Apr 2004 09:26:40 GMT
sylvain     2004/04/14 02:26:40

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/formmodel
                        Field.java Union.java
  Log:
  Fixing early validation (already fixed in cforms)
  
  Revision  Changes    Path
  1.29      +2 -16     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Field.java
  
  Index: Field.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Field.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Field.java	9 Mar 2004 13:53:56 -0000	1.28
  +++ Field.java	14 Apr 2004 09:26:40 -0000	1.29
  @@ -49,7 +49,6 @@
   
       protected String enteredValue;
       protected Object value;
  -    private Object oldValue;
   
       // At startup, we don't need to parse (both enteredValue and value are null),
       // but need to validate (error if field is required)
  @@ -72,10 +71,6 @@
           return definition.getId();
       }
   
  -    public Object getOldValue() {
  -        return oldValue;
  -    }
  -
       public Object getValue() {
           // Parse the value
           if (this.needsParse) {
  @@ -156,9 +151,6 @@
                   getForm().addWidgetEvent(new ValueChangedEvent(this, oldValue, newValue));
               }
           }
  -        // If set comes before a form is first sent then the new value will be the old
value by the time of the next form request.
  -        // If the set occurs in an event handler then again the new value will be the old
value by the time of the next form request.
  -        this.oldValue = newValue;
       }
   
       public void readFromRequest(FormContext formContext) {
  @@ -176,16 +168,10 @@
               }
           }
   
  -        // TODO: This cause validation to occur too early.
  -        getValue();
  -        this.oldValue = value;
  -
           // Only convert if the text value actually changed. Otherwise, keep the old value
           // and/or the old validation error (allows to keep errors when clicking on actions)
           if (!(newEnteredValue == null ? "" : newEnteredValue).equals((enteredValue == null
? "" : enteredValue))) {
  -            // TODO: Hmmm...
  -            //getForm().addWidgetEvent(new DeferredValueChangedEvent(this, value));
  -            getForm().addWidgetEvent(new DeferredValueChangedEvent(this, getValue()));
  +            getForm().addWidgetEvent(new DeferredValueChangedEvent(this, value));
               enteredValue = newEnteredValue;
               validationError = null;
               value = null;
  
  
  
  1.7       +5 -7      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Union.java
  
  Index: Union.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Union.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Union.java	9 Mar 2004 13:53:56 -0000	1.6
  +++ Union.java	14 Apr 2004 09:26:40 -0000	1.7
  @@ -62,18 +62,16 @@
           return ELEMENT;
       }
   
  -    public Object getOldValue() {
  -        return ((Field)caseWidget).getOldValue();
  -    }
  -
       public Object getValue() {
           return caseWidget.getValue();
       }
   
       public void readFromRequest(FormContext formContext) {
  +        // Ensure the case widgets got its value
  +        caseWidget.readFromRequest(formContext);
           Widget widget;
           // Read current case from request
  -        String value = (String)getOldValue();
  +        String value = (String)getValue();
           if (value != null && !value.equals(""))
               if ((widget = getWidget(value)) != null)
                   widget.readFromRequest(formContext);
  @@ -87,7 +85,7 @@
           Widget widget;
           boolean valid = true;
           // Read current case from request
  -        String value = (String)getOldValue();
  +        String value = (String)getValue();
           if (value != null && !value.equals(""))
               if ((widget = getWidget(value)) != null)
                   valid = valid & widget.validate(formContext);
  
  
  

Mime
View raw message