You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by re...@apache.org on 2020/02/23 07:09:06 UTC

[wicket] branch improvement/reiern70/abort-ajax-qeruest-in-a-channel created (now 1b43e87)

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

reiern70 pushed a change to branch improvement/reiern70/abort-ajax-qeruest-in-a-channel
in repository https://gitbox.apache.org/repos/asf/wicket.git.


      at 1b43e87  [NO_ISSUE] allow to abort currently executing request for an Ajax channel

This branch includes the following new commits:

     new 1b43e87  [NO_ISSUE] allow to abort currently executing request for an Ajax channel

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[wicket] 01/01: [NO_ISSUE] allow to abort currently executing request for an Ajax channel

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reiern70 pushed a commit to branch improvement/reiern70/abort-ajax-qeruest-in-a-channel
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit 1b43e87c59ddf02c4020149b898758a0f1c6125e
Author: reiern70 <re...@gmail.com>
AuthorDate: Sun Feb 23 09:08:57 2020 +0200

    [NO_ISSUE] allow to abort currently executing request for an Ajax channel
---
 .../wicket/ajax/res/js/wicket-ajax-jquery.js       | 34 +++++++++++++++++++++-
 1 file changed, 33 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 3ee9f3b..c786b91 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
@@ -278,6 +278,15 @@
 			}
 		},
 
+		// aborts current request is there is any running
+		abort: function () {
+			if (isUndef(this.jqXHR)) {
+				Wicket.Log.debug("There is no executing request fro channel " + this.name)
+			} else {
+				this.jqXHR.abort();
+			}
+		},
+
 		done: function () {
 			var callback = null;
 
@@ -319,6 +328,26 @@
 			return c.schedule(callback);
 		},
 
+		// register AJAX request
+		registerCurrentAjaxRequest: function(name, jqXHR) {
+			var c = this.channels[name];
+			if (isUndef(c)) {
+				Wicket.Log.error("No channel with name " + name)
+			} else {
+				c.jqXHR = jqXHR;
+			}
+		},
+
+		// aborts the current request for channel with name name
+		abortCurrentQuestForChannel(name) {
+			var c = this.channels[name];
+			if (isUndef(c)) {
+				Wicket.Log.error("No channel with name " + name)
+			} else {
+				c.abort();
+			}
+		},
+
 		// Tells the ChannelManager that the current callback in channel with given name
 		// has finished processing and another scheduled callback can be executed (if any).
 		done: function (channel) {
@@ -549,7 +578,10 @@
 			this._initializeDefaults(attrs);
 
 			var res = Wicket.channelManager.schedule(attrs.ch, Wicket.bind(function () {
-				this.doAjax(attrs);
+				var jqXHR = this.doAjax(attrs);
+				if (attrs.async) {
+					Wicket.ChannelManager.registerCurrentAjaxRequest(attrs.c, jqXHR);
+				}
 			}, this));
 			return res !== null ? res: true;
 		},