This is an automated email from the ASF dual-hosted git repository.

adelbene pushed a commit to branch wicket-9.x
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit 9f4dbf7eb2082fd1e5e1ff320118ec4e95c06341
Author: Andreas Svanberg <andreas.svanb...@mensa.se>
AuthorDate: Fri Oct 20 13:46:04 2023 +0200

    Fall back to jQuery event triggering if requestSubmit() is not available
---
 .../org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js  | 16 ++++++++++++++++
 .../java/org/apache/wicket/markup/html/form/Form.java    |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js 
b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index 7eaa51a96e..1f29dbc0c7 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -2421,6 +2421,22 @@
                                }
                        },
 
+                       /**
+                        * Submits the given form using, if available, standard 
form processing
+                        * including client-side validation and firing of 
SubmitEvent.
+                        * If it is not available, uses jQuery event triggering 
to submit the form
+                        * and send out the SubmitEvent.
+                        *
+                        * @param form {HTMLFormElement} form to submit
+                        */
+                       requestSubmit: function(form) {
+                               if (form.requestSubmit) {
+                                       form.requestSubmit();
+                               } else {
+                                       jQuery(form).trigger('submit');
+                               }
+                       },
+
                        /**
                         * The names of the topics on which Wicket notifies
                         */
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
index cc33672cf4..0a4971f3e4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
@@ -600,7 +600,7 @@ public class Form<T> extends WebMarkupContainer
 
                if (triggerEvent)
                {
-                       buffer.append("f.requestSubmit();");
+                       buffer.append("Wicket.Event.requestSubmit(f);");
                }
                else
                {

Reply via email to