Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 92203 invoked from network); 29 Nov 2005 20:45:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Nov 2005 20:45:12 -0000 Received: (qmail 30947 invoked by uid 500); 29 Nov 2005 20:45:11 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 30806 invoked by uid 500); 29 Nov 2005 20:45:10 -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: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 30795 invoked by uid 99); 29 Nov 2005 20:45:10 -0000 X-ASF-Spam-Status: No, hits=-9.4 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.29) with SMTP; Tue, 29 Nov 2005 12:45:10 -0800 Received: (qmail 91959 invoked by uid 65534); 29 Nov 2005 20:44:50 -0000 Message-ID: <20051129204450.91958.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r349805 - /cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Form.java Date: Tue, 29 Nov 2005 20:44:49 -0000 To: cvs@cocoon.apache.org From: sylvain@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: sylvain Date: Tue Nov 29 12:44:40 2005 New Revision: 349805 URL: http://svn.apache.org/viewcvs?rev=349805&view=rev Log: Fixing the fix that fixed the fix (and vice versa) Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Form.java Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Form.java URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Form.java?rev=349805&r1=349804&r2=349805&view=diff ============================================================================== --- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Form.java (original) +++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Form.java Tue Nov 29 12:44:40 2005 @@ -31,6 +31,7 @@ import org.apache.cocoon.forms.validation.ValidationErrorAware; import org.apache.commons.collections.list.CursorableLinkedList; import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.StringUtils; /** * A widget that serves as a container for other widgets, the top-level widget in @@ -202,7 +203,11 @@ * @param widget the widget */ public void setSubmitWidget(Widget widget) { - if (this.submitWidget != null && this.submitWidget != widget) { + if (this.submitWidget == widget) { + return; + } + + if (this.submitWidget != null) { throw new IllegalStateException("Submit widget already set to " + this.submitWidget + ". Cannot set also " + widget); } @@ -305,37 +310,33 @@ // Start buffering events this.bufferEvents = true; + this.submitWidget = null; + doReadFromRequest(formContext); + // Find the submit widget, if not an action + // This has to occur after reading from the request, to handle stateless forms + // where the submit widget is recreated when the request is read (e.g. a row-action). + String submitId = formContext.getRequest().getParameter(SUBMIT_ID_PARAMETER); + if (!StringUtils.isEmpty(submitId)) { + // if the form has an ID, it is used as part of the submitId too and must be removed + if(!StringUtils.isEmpty(this.getId())) { + submitId = submitId.substring(submitId.indexOf('.')+1); + } + Widget submit = this.lookupWidget(submitId.replace('.', '/')); + if (submit == null) { + throw new IllegalArgumentException("Invalid submit id (no such widget): " + submitId); + } + setSubmitWidget(submit); + } + // Fire events, still buffering them: this ensures they will be handled in the same // order as they were added. fireEvents(); + } finally { // No need for buffering in the following phases this.bufferEvents = false; - } - - // Find the submit widget, if not an action - // This has to occur after reading from the request, to handle stateless forms - // where the submit widget is recreated when the request is read (e.g. a row-action). - this.submitWidget = null; - String submitId = formContext.getRequest().getParameter(SUBMIT_ID_PARAMETER); - if (submitId != null && submitId.length() > 0) { - // if the form has an ID, it is used as part of the submitId too - // this has ID has to be cut off - if(this.getId() != null && !"".equals(this.getId())) { - submitId = submitId.substring(submitId.indexOf('.')+1); - } - StringTokenizer stok = new StringTokenizer(submitId, "."); - Widget submit = this; - while (stok.hasMoreTokens()) { - submit = submit.lookupWidget(stok.nextToken()); - if (submit == null) { - throw new IllegalArgumentException("Invalid submit id (no such widget): " + submitId); - } - } - - setSubmitWidget(submit); } // Notify the end of the current phase