AjaxFormSubmitBehavior cannot be applied to Form
------------------------------------------------

                 Key: WICKET-2398
                 URL: https://issues.apache.org/jira/browse/WICKET-2398
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 1.4.0
            Reporter: John Patterson
            Priority: Minor


I need to apply the above behavior directly to a Form rather than to one of its 
children.  This is so I can listen to the "onsubmit" event of the form itself 
rather than attach it to a button.

This patch allows you to do this

Index: AjaxFormSubmitBehavior.java
===================================================================
--- AjaxFormSubmitBehavior.java (revision 797714)
+++ AjaxFormSubmitBehavior.java (working copy)
@@ -86,13 +86,20 @@
                {
                        // try to find form in the hierarchy of owning component
                        Component component = getComponent();
-                       __form = component.findParent(Form.class);
-                       if (__form == null)
+                       if (component instanceof Form)
+                       {
+                               __form = (Form<?>)component;
+                       }
+                       else
                        {
-                               throw new IllegalStateException(
-                                       "form was not specified in the 
constructor and cannot "
-                                               + "be found in the hierarchy of 
the component this behavior "
-                                               + "is attached to");
+                               __form = component.findParent(Form.class);
+                               if (__form == null)
+                               {
+                                       throw new IllegalStateException(
+                                               "form was not specified in the 
constructor and cannot "
+                                                       + "be found in the 
hierarchy of the component this behavior "
+                                                       + "is attached to");
+                               }
                        }
                }
                return __form;


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to