Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 15693 invoked from network); 20 Oct 2005 14:07:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Oct 2005 14:07:02 -0000 Received: (qmail 23318 invoked by uid 500); 20 Oct 2005 14:07:02 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 23268 invoked by uid 500); 20 Oct 2005 14:07:01 -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 23257 invoked by uid 99); 20 Oct 2005 14:07:01 -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; Thu, 20 Oct 2005 07:07:01 -0700 Received: (qmail 15526 invoked by uid 65534); 20 Oct 2005 14:06:41 -0000 Message-ID: <20051020140641.15525.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r326907 - /cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Form.java Date: Thu, 20 Oct 2005 14:06:40 -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: Thu Oct 20 07:06:37 2005 New Revision: 326907 URL: http://svn.apache.org/viewcvs?rev=326907&view=rev Log: More comments, forbid submission by an inactive widget 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=326907&r1=326906&r2=326907&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 Thu Oct 20 07:06:37 2005 @@ -47,6 +47,12 @@ private final FormDefinition definition; + /** + * If non-null, indicates that form processing should terminate at the end of the current phase. + * If true, interaction with the form is finished. It doesn't imply that the form is valid though. + * If false, interaction isn't finished and the form should be redisplayed (processing was triggered + * by e.g. and action or a field with event listeners). + */ private Boolean endProcessing; private Locale locale = Locale.getDefault(); private FormHandler formHandler; @@ -197,6 +203,16 @@ throw new IllegalStateException("SubmitWidget already set to " + this.submitWidget + ". Cannot set also " + widget); } + + // Check that the submit widget is active + if (widget.getCombinedState() != WidgetState.ACTIVE) { + throw new IllegalStateException("Widget " + widget + " that submited the form is not active."); + } + + // If the submit widget is not an action (e.g. a field with an event listener), + // we end form processing after the current phase and redisplay the form. + // Actions (including submits) will call endProcessing() themselves and it's their + // responsibility to indicate how form processing should continue. if (!(widget instanceof Action)) { endProcessing(true); } @@ -333,7 +349,10 @@ * @param redisplayForm indicates if the form should be redisplayed to the user. */ public void endProcessing(boolean redisplayForm) { - this.endProcessing = BooleanUtils.toBooleanObject(!redisplayForm); + // Set the indicator that terminates the form processing. + // If redisplayForm is true, interaction is not finished and process() must + // return false, hence the negation below. + this.endProcessing = BooleanUtils.toBooleanObject( !redisplayForm ); } /**