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/forms/java/org/apache/cocoon/forms/formmodel Field.java Union.java
Date Tue, 13 Apr 2004 21:28:24 GMT
sylvain     2004/04/13 14:28:24

  Modified:    src/blocks/forms/java/org/apache/cocoon/forms/formmodel
                        Field.java Union.java
  Log:
  Avoid to always validate in ReadFromRequest()
  
  Revision  Changes    Path
  1.7       +9 -22     cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
  
  Index: Field.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Field.java	10 Apr 2004 13:41:41 -0000	1.6
  +++ Field.java	13 Apr 2004 21:28:24 -0000	1.7
  @@ -48,11 +48,10 @@
   public class Field extends AbstractWidget implements ValidationErrorAware, DataWidget,
SelectableWidget {
       protected SelectionList selectionList;
       
  -    private final FieldDefinition definition;
  +    private final FieldDefinition fieldDefinition;
   
       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)
  @@ -63,19 +62,15 @@
   
   
       public Field(FieldDefinition fieldDefinition) {
  -        this.definition = fieldDefinition;
  +        this.fieldDefinition = fieldDefinition;
       }
   
       public final FieldDefinition getFieldDefinition() {
  -        return this.definition;
  +        return this.fieldDefinition;
       }
   
       protected WidgetDefinition getDefinition() {
  -        return this.definition;
  -    }
  -
  -    public Object getOldValue() {
  -        return oldValue;
  +        return this.fieldDefinition;
       }
   
       public Object getValue() {
  @@ -158,9 +153,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) {
  @@ -178,16 +170,11 @@
               }
           }
   
  -        // 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;
  @@ -257,7 +244,7 @@
           }
   
           // generate label, help, hint, etc.
  -        definition.generateDisplayData(contentHandler);
  +        fieldDefinition.generateDisplayData(contentHandler);
   
           // generate selection list, if any
           if (selectionList != null) {
  @@ -267,13 +254,13 @@
           }
   
           // include some info about the datatype
  -        definition.getDatatype().generateSaxFragment(contentHandler, locale);
  +        fieldDefinition.getDatatype().generateSaxFragment(contentHandler, locale);
   
           contentHandler.endElement(Constants.INSTANCE_NS, FIELD_EL, Constants.INSTANCE_PREFIX_COLON
+ FIELD_EL);
       }
   
       public void generateLabel(ContentHandler contentHandler) throws SAXException {
  -        definition.generateLabel(contentHandler);
  +        fieldDefinition.generateLabel(contentHandler);
       }
   
       /**
  
  
  
  1.4       +6 -7      cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java
  
  Index: Union.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Union.java	12 Apr 2004 14:05:09 -0000	1.3
  +++ Union.java	13 Apr 2004 21:28:24 -0000	1.4
  @@ -66,18 +66,17 @@
           return ELEMENT;
       }
   
  -    public Object getOldValue() {
  -        return ((Field)caseWidget).getOldValue();
  -    }
  -
       public Object getValue() {
           return caseWidget.getValue();
       }
   
       public void readFromRequest(FormContext formContext) {
  +        // Ensure the case widget has read 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);
  @@ -91,7 +90,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