Updated Branches:
  refs/heads/sandbox/formsubmit-beforeafter-1.5 cdcd4b5c0 -> 7da00025e


added Ajax(Fallback)Button


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/7da00025
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/7da00025
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/7da00025

Branch: refs/heads/sandbox/formsubmit-beforeafter-1.5
Commit: 7da00025eea79f5a0892887a60f9ce75290b28a4
Parents: cdcd4b5
Author: Carl-Eric Menzel <[email protected]>
Authored: Tue Jun 19 16:21:24 2012 +0200
Committer: Carl-Eric Menzel <[email protected]>
Committed: Tue Jun 19 16:21:24 2012 +0200

----------------------------------------------------------------------
 .../wicket/ajax/markup/html/form/AjaxButton.java   |   51 ++++++++++-
 .../ajax/markup/html/form/AjaxFallbackButton.java  |   72 ++++++++++++++-
 2 files changed, 119 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/7da00025/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
 
b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
index c113db1..dcffebb 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
@@ -23,6 +23,7 @@ import org.apache.wicket.ajax.IAjaxCallDecorator;
 import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
 import org.apache.wicket.markup.html.form.Button;
 import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.IFormSubmitter;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
@@ -105,6 +106,26 @@ public abstract class AjaxButton extends Button
 
                        /**
                         * 
+                        * @see 
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
+                        */
+                       @Override
+                       protected void onSubmitBeforeForm(AjaxRequestTarget 
target)
+                       {
+                               AjaxButton.this.onSubmitBeforeForm(target, 
AjaxButton.this.getForm());
+                       }
+
+                       /**
+                        * 
+                        * @see 
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
+                        */
+                       @Override
+                       protected void onSubmitAfterForm(AjaxRequestTarget 
target)
+                       {
+                               AjaxButton.this.onSubmitAfterForm(target, 
AjaxButton.this.getForm());
+                       }
+
+                       /**
+                        * 
                         * @see 
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior#onError(org.apache.wicket.ajax.AjaxRequestTarget)
                         */
                        @Override
@@ -203,8 +224,32 @@ public abstract class AjaxButton extends Button
         * 
         * @param target
         * @param form
+        * @deprecated see {@link IFormSubmitter#onSubmit()}
+        */
+       @Deprecated
+       protected void onSubmit(AjaxRequestTarget target, Form<?> form)
+       {
+       }
+
+       /**
+        * Listener method invoked on form submit with no errors
+        * 
+        * @param target
+        * @param form
         */
-       protected abstract void onSubmit(AjaxRequestTarget target, Form<?> 
form);
+       protected void onSubmitBeforeForm(AjaxRequestTarget target, Form<?> 
form)
+       {
+       }
+
+       /**
+        * Listener method invoked on form submit with no errors
+        * 
+        * @param target
+        * @param form
+        */
+       protected void onSubmitAfterForm(AjaxRequestTarget target, Form<?> form)
+       {
+       }
 
        /**
         * Listener method invoked on form submit with errors
@@ -212,5 +257,7 @@ public abstract class AjaxButton extends Button
         * @param target
         * @param form
         */
-       protected abstract void onError(AjaxRequestTarget target, Form<?> form);
+       protected void onError(AjaxRequestTarget target, Form<?> form)
+       {
+       }
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/7da00025/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java
 
b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java
index 4a54fb8..e945f9a 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java
@@ -23,6 +23,7 @@ import org.apache.wicket.ajax.IAjaxCallDecorator;
 import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
 import org.apache.wicket.markup.html.form.Button;
 import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.IFormSubmitter;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 
@@ -77,6 +78,19 @@ public abstract class AjaxFallbackButton extends Button
                        }
 
                        @Override
+                       protected void onSubmitBeforeForm(AjaxRequestTarget 
target)
+                       {
+                               
AjaxFallbackButton.this.onSubmitBeforeForm(target,
+                                       AjaxFallbackButton.this.getForm());
+                       }
+
+                       @Override
+                       protected void onSubmitAfterForm(AjaxRequestTarget 
target)
+                       {
+                               
AjaxFallbackButton.this.onSubmitAfterForm(target, 
AjaxFallbackButton.this.getForm());
+                       }
+
+                       @Override
                        protected void onError(AjaxRequestTarget target)
                        {
                                AjaxFallbackButton.this.onError(target, 
AjaxFallbackButton.this.getForm());
@@ -114,7 +128,9 @@ public abstract class AjaxFallbackButton extends Button
         * @param target
         * @param form
         */
-       protected abstract void onError(AjaxRequestTarget target, Form<?> form);
+       protected void onError(AjaxRequestTarget target, Form<?> form)
+       {
+       }
 
        /**
         * @see 
org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
@@ -129,6 +145,30 @@ public abstract class AjaxFallbackButton extends Button
        }
 
        /**
+        * @see 
org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
+        */
+       @Override
+       public final void onSubmitBeforeForm()
+       {
+               if (AjaxRequestTarget.get() == null)
+               {
+                       onSubmitBeforeForm(null, getForm());
+               }
+       }
+
+       /**
+        * @see 
org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
+        */
+       @Override
+       public final void onSubmitAfterForm()
+       {
+               if (AjaxRequestTarget.get() == null)
+               {
+                       onSubmitAfterForm(null, getForm());
+               }
+       }
+
+       /**
         * 
         * @see org.apache.wicket.markup.html.form.Button#getForm()
         */
@@ -145,8 +185,36 @@ public abstract class AjaxFallbackButton extends Button
         * @param target
         *            ajax target if this linked was invoked using ajax, null 
otherwise
         * @param form
+        * @deprecated see {@link IFormSubmitter#onSubmit()}
+        */
+       @Deprecated
+       protected void onSubmit(final AjaxRequestTarget target, final Form<?> 
form)
+       {
+       }
+
+       /**
+        * Callback for the onClick event. If ajax failed and this event was 
generated via a normal
+        * submission, the target argument will be null
+        * 
+        * @param target
+        *            ajax target if this linked was invoked using ajax, null 
otherwise
+        * @param form
         */
-       protected abstract void onSubmit(final AjaxRequestTarget target, final 
Form<?> form);
+       protected void onSubmitBeforeForm(final AjaxRequestTarget target, final 
Form<?> form)
+       {
+       }
+
+       /**
+        * Callback for the onClick event. If ajax failed and this event was 
generated via a normal
+        * submission, the target argument will be null
+        * 
+        * @param target
+        *            ajax target if this linked was invoked using ajax, null 
otherwise
+        * @param form
+        */
+       protected void onSubmitAfterForm(final AjaxRequestTarget target, final 
Form<?> form)
+       {
+       }
 
        /**
         * 

Reply via email to