Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 27599 invoked from network); 11 Jul 2004 17:19:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 11 Jul 2004 17:19:59 -0000 Received: (qmail 66945 invoked by uid 500); 11 Jul 2004 17:19:59 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 66777 invoked by uid 500); 11 Jul 2004 17:19:58 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 66763 invoked by uid 500); 11 Jul 2004 17:19:58 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 66760 invoked by uid 99); 11 Jul 2004 17:19:58 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Sun, 11 Jul 2004 10:19:54 -0700 Received: (qmail 27530 invoked by uid 1342); 11 Jul 2004 17:19:54 -0000 Date: 11 Jul 2004 17:19:54 -0000 Message-ID: <20040711171954.27529.qmail@minotaur.apache.org> From: vgritsenko@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel AggregateField.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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); }