cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel AggregateField.java
Date Sun, 11 Jul 2004 17:19:54 GMT
vgritsenko    2004/07/11 10:19:54

  Modified:    src/blocks/forms/java/org/apache/cocoon/forms/formmodel
                        AggregateField.java
  Log:
  Attempt to fix aggregate field after Field refactorings (states, etc).
  Demo seems to be working now.
  
  Revision  Changes    Path
  1.12      +20 -14    cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
  
  Index: AggregateField.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AggregateField.java	29 Jun 2004 13:06:04 -0000	1.11
  +++ AggregateField.java	11 Jul 2004 17:19:54 -0000	1.12
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -73,11 +73,12 @@
       }
   
       public void addChild(Widget widget) {
  -    	if (!(widget instanceof Field)) 
  +    	if (!(widget instanceof Field)) {
               throw new IllegalArgumentException("AggregateField can only contain fields.");
  +        }
           addField((Field)widget);
  -    }   
  -    
  +    }
  +
       protected void addField(Field field) {
           field.setParent(this);
           fields.add(field);
  @@ -103,7 +104,6 @@
               }
           } else {
               // Check if there are multiple splitted values. Read them and aggregate them.
  -            boolean needsParse = false;
               for (Iterator i = fields.iterator(); i.hasNext();) {
                   Field field = (Field)i.next();
                   field.readFromRequest(formContext);
  @@ -111,7 +111,7 @@
                       this.valueState = VALUE_UNPARSED;
                   }
               }
  -            if (needsParse) {
  +            if (this.valueState == VALUE_UNPARSED) {
                   combineFields();
               }
           }
  @@ -187,7 +187,7 @@
       }
   
       public boolean validate() {
  -        if ((enteredValue != null) != fieldsHaveValues()) {
  +        if (enteredValue != null && !fieldsHaveValues()) {
               XMLizable failMessage = getAggregateFieldDefinition().getSplitFailMessage();
               if (failMessage != null) {
                   validationError = new ValidationError(failMessage);
  @@ -196,17 +196,23 @@
                                                                         new String[] { getAggregateFieldDefinition().getSplitRegexp()
},
                                                                         Constants.I18N_CATALOGUE));
               }
  +            valueState = VALUE_DISPLAY_VALIDATION;
               return false;
           }
   
  -        // validate my child fields
  +        // Validate ALL my child fields
  +        boolean valid = true;
           for (Iterator i = fields.iterator(); i.hasNext();) {
               Field field = (Field)i.next();
               if (!field.validate()) {
                   validationError = field.getValidationError();
  -                return false;
  +                valid = false;
               }
           }
  +        if (!valid) {
  +            valueState = VALUE_DISPLAY_VALIDATION;
  +            return false;
  +        }
   
           return super.validate();
       }
  @@ -216,10 +222,10 @@
       /**
        * @return "aggregatefield"
        */
  -    public String getXMLElementName() {        
  +    public String getXMLElementName() {
           return AGGREGATEFIELD_EL;
       }
  -      
  +
       public Widget getChild(String id) {
           return (Widget)fieldsById.get(id);
       }
  
  
  

Mime
View raw message