Author: ivaynberg
Date: Tue Jun 28 22:26:32 2011
New Revision: 1140871

URL: http://svn.apache.org/viewvc?rev=1140871&view=rev
Log:

Issue: WICKET-3840

Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java?rev=1140871&r1=1140870&r2=1140871&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
 Tue Jun 28 22:26:32 2011
@@ -87,29 +87,39 @@ public abstract class AjaxFormSubmitBeha
        {
                if (__form == null)
                {
-                       // try to find form in the hierarchy of owning component
-                       Component component = getComponent();
-                       if (component instanceof Form<?>)
-                       {
-                               __form = (Form<?>)component;
-                       }
-                       else
-                       {
-                               __form = component.findParent(Form.class);
-                       }
+                       __form = findForm();
 
                        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: Component=" + 
component.toString(false));
+                                               "is attached to: Component=" + 
getComponent().toString(false));
                        }
                }
                return __form;
        }
 
        /**
+        * Finds form that will be submitted
+        * 
+        * @return form to submit or {@code null} if none found
+        */
+       protected Form<?> findForm()
+       {
+               // try to find form in the hierarchy of owning component
+               Component component = getComponent();
+               if (component instanceof Form<?>)
+               {
+                       return (Form<?>)component;
+               }
+               else
+               {
+                       return component.findParent(Form.class);
+               }
+       }
+
+       /**
         * 
         * @see org.apache.wicket.ajax.AjaxEventBehavior#getEventHandler()
         */

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java?rev=1140871&r1=1140870&r2=1140871&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
 Tue Jun 28 22:26:32 2011
@@ -87,6 +87,12 @@ public abstract class AjaxSubmitLink ext
                        }
 
                        @Override
+                       protected Form<?> findForm()
+                       {
+                               return AjaxSubmitLink.this.getForm();
+                       }
+
+                       @Override
                        protected void onComponentTag(ComponentTag tag)
                        {
                                // write the onclick handler only if link is 
enabled


Reply via email to