You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/09/22 21:08:32 UTC

svn commit: r291005 - /cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/FormDefinition.java

Author: sylvain
Date: Thu Sep 22 12:08:29 2005
New Revision: 291005

URL: http://svn.apache.org/viewcvs?rev=291005&view=rev
Log:
Forbid toplevel "submit" only if the form has no id

Modified:
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/FormDefinition.java

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/FormDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/FormDefinition.java?rev=291005&r1=291004&r2=291005&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/FormDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/FormDefinition.java Thu Sep 22 12:08:29 2005
@@ -23,6 +23,7 @@
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
 import org.apache.cocoon.forms.formmodel.library.Library;
 import org.apache.cocoon.forms.formmodel.library.LibraryManager;
+import org.apache.commons.lang.StringUtils;
 
 /**
  * The {@link WidgetDefinition} part of a Form widget, see {@link Form} for more information.
@@ -73,10 +74,10 @@
     }
     
     public void addWidgetDefinition(WidgetDefinition definition) throws Exception, DuplicateIdException {
-        // Check that no child is named "submit". This causes some weird behaviour in HTML as
-        // it collides with the submit() function on the <form> element...
-        if ("submit".equals(definition.getId())) {
-            throw new IllegalArgumentException("No top-level widget should be named 'submit' to avoid problems "
+        // Check that no child is named "submit" if this form has no id. This causes some weird behaviour
+        // in HTML as it collides with the submit() function on the <form> element...
+        if ("submit".equals(definition.getId()) && StringUtils.isEmpty(this.getId())) {
+            throw new IllegalArgumentException("Top-level widgets should not be named 'submit' to avoid problems "
                     + " with HTML <form> elements, at " + definition.getLocation());
         }