Author: ivaynberg
Date: Wed Jun 17 16:05:24 2009
New Revision: 785696

URL: http://svn.apache.org/viewvc?rev=785696&view=rev
Log:
WICKET-2330 fixed npe in ajaxformsubmitbehavior
Issue: WICKET-2330

Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java?rev=785696&r1=785695&r2=785696&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
 Wed Jun 17 16:05:24 2009
@@ -40,7 +40,11 @@
 {
        private static final long serialVersionUID = 1L;
 
-       private Form<?> form;
+       /**
+        * should never be accessed directly (thus the __ cause its overkil to 
create a super class),
+        * instead always use #getForm()
+        */
+       private Form<?> __form;
 
        /**
         * Constructor. This constructor can only be used when the component 
this behavior is attached
@@ -65,7 +69,7 @@
        public AjaxFormSubmitBehavior(Form<?> form, String event)
        {
                super(event);
-               this.form = form;
+               __form = form;
 
                if (form != null)
                {
@@ -79,12 +83,12 @@
         */
        protected Form<?> getForm()
        {
-               if (form == null)
+               if (__form == null)
                {
                        // try to find form in the hierarchy of owning component
                        Component component = getComponent();
-                       form = component.findParent(Form.class);
-                       if (form == null)
+                       __form = component.findParent(Form.class);
+                       if (__form == null)
                        {
                                throw new IllegalStateException(
                                        "form was not specified in the 
constructor and cannot "
@@ -92,7 +96,7 @@
                                                + "is attached to");
                        }
                }
-               return form;
+               return __form;
        }
 
        /**
@@ -139,7 +143,7 @@
                {
                        onSubmit(target);
                }
-               if (form.findParent(Page.class) != null)
+               if (getForm().findParent(Page.class) != null)
                {
                        /*
                         * there can be cases when a form is replaced with 
another component in the onsubmit()


Reply via email to