You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/05/13 14:21:56 UTC

git commit: WICKET-5178 StopPropagation functionality on link is broken WICKET-5093 The event listener in Wicket.Ajax.ajax() should not return the value of attrs.ad (allowDefault)

Updated Branches:
  refs/heads/master 62562dc45 -> a11ce8a7e


WICKET-5178 StopPropagation functionality on link is broken
WICKET-5093 The event listener in Wicket.Ajax.ajax() should not return the value of attrs.ad (allowDefault)


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

Branch: refs/heads/master
Commit: a11ce8a7e3b575385d8f03db62130517a2b80d09
Parents: 62562dc
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon May 13 15:21:05 2013 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon May 13 15:21:05 2013 +0300

----------------------------------------------------------------------
 .../wicket/ajax/AbstractDefaultAjaxBehavior.java   |    8 +-
 .../wicket/ajax/attributes/AjaxAttributeName.java  |    4 +-
 .../ajax/attributes/AjaxRequestAttributes.java     |   16 ++--
 .../wicket/ajax/res/js/wicket-ajax-jquery.js       |   55 +++++++--------
 4 files changed, 41 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/a11ce8a7/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
index 49264c8..1cd9ec6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
@@ -345,13 +345,13 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior
 				attributesJson.put(AjaxAttributeName.IS_ALLOW_DEFAULT.jsonName(), true);
 			}
 
-			if (AjaxRequestAttributes.StopPropagation.NO.equals(attributes.getStopPropagation()))
+			if (AjaxRequestAttributes.EventPropagation.BUBBLE.equals(attributes.getEventPropagation()))
 			{
-				attributesJson.put(AjaxAttributeName.STOP_PROPAGATION.jsonName(), "no");
+				attributesJson.put(AjaxAttributeName.EVENT_PROPAGATION.jsonName(), "bubble");
 			}
-			else if (AjaxRequestAttributes.StopPropagation.STOP_IMMEDIATE.equals(attributes.getStopPropagation()))
+			else if (AjaxRequestAttributes.EventPropagation.STOP_IMMEDIATE.equals(attributes.getEventPropagation()))
 			{
-				attributesJson.put(AjaxAttributeName.STOP_PROPAGATION.jsonName(), "stopImmediate");
+				attributesJson.put(AjaxAttributeName.EVENT_PROPAGATION.jsonName(), "stopImmediate");
 			}
 
 			Duration requestTimeout = attributes.getRequestTimeout();

http://git-wip-us.apache.org/repos/asf/wicket/blob/a11ce8a7/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
index 4305fae..1042deb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
@@ -85,9 +85,9 @@ public enum AjaxAttributeName {
 	/**
 	 * stop propagation
 	 *
-	 * @see AjaxRequestAttributes#setStopPropagation(org.apache.wicket.ajax.attributes.AjaxRequestAttributes.StopPropagation)
+	 * @see AjaxRequestAttributes#setEventPropagation(org.apache.wicket.ajax.attributes.AjaxRequestAttributes.EventPropagation)
 	 */
-	STOP_PROPAGATION("sp"),
+	EVENT_PROPAGATION("sp"),
 
 	/**
 	 * channel (ch)

http://git-wip-us.apache.org/repos/asf/wicket/blob/a11ce8a7/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
index cc7386c..896c4fd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
@@ -53,7 +53,7 @@ public final class AjaxRequestAttributes
 	/**
 	 * The JavaScript event propagation type
 	 */
-	public static enum StopPropagation
+	public static enum EventPropagation
 	{
 		/**
 		 * Stops the propagation of the JavaScript event to the parent of its target
@@ -69,7 +69,7 @@ public final class AjaxRequestAttributes
 		/**
 		 * Do not stop the propagation of the JavaScript event
 		 */
-		NO
+		BUBBLE
 	}
 
 	public static final String XML_DATA_TYPE = "xml";
@@ -82,7 +82,7 @@ public final class AjaxRequestAttributes
 
 	private boolean allowDefault = false;
 
-	private StopPropagation stopPropagation = StopPropagation.STOP;
+	private EventPropagation eventPropagation = EventPropagation.STOP;
 
 	/**
 	 * The names of the events which will trigger the Ajax call
@@ -307,9 +307,9 @@ public final class AjaxRequestAttributes
 	 * Only applies for event behaviors. Returns whether the behavior should allow the JavaScript event
 	 * to propagate to the parent of its target.
 	 */
-	public StopPropagation getStopPropagation()
+	public EventPropagation getEventPropagation()
 	{
-		return stopPropagation;
+		return eventPropagation;
 	}
 
 	/**
@@ -332,13 +332,13 @@ public final class AjaxRequestAttributes
 	 * Only applies to event behaviors. Determines whether the behavior should allow the
 	 * JavaScript event to propagate to the parent of its target.
 	 *
-	 * @param stopPropagation
+	 * @param eventPropagation
 	 *      the type of the stop
 	 * @return {@code this} object, for chaining
 	 */
-	public AjaxRequestAttributes setStopPropagation(StopPropagation stopPropagation)
+	public AjaxRequestAttributes setEventPropagation(EventPropagation eventPropagation)
 	{
-		this.stopPropagation = Args.notNull(stopPropagation, "stopPropagation");
+		this.eventPropagation = Args.notNull(eventPropagation, "eventPropagation");
 		return this;
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/a11ce8a7/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
----------------------------------------------------------------------
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 7b3f34a..e4930ec 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
@@ -443,31 +443,6 @@
 		},
 
 		/**
-		 * Aborts the default event if attributes request it
-		 *
-		 * @param {Object} attrs - the Ajax request attributes configured at the server side
-		 */
-		_handleEventCancelation: function(attrs) {
-			var evt = attrs.event;
-			if (evt) {
-				if (!attrs.ad) {
-					try {
-						evt.preventDefault();
-					} catch (ignore) {
-						// WICKET-4986
-						// jquery fails 'member not found' with calls on busy channel
-					}
-				}
-
-				if (attrs.sp === "stop") {
-					Wicket.Event.stop(evt);
-				} else if (attrs.sp === "stopImmediate") {
-					Wicket.Event.stop(evt, true);
-				}
-			}
-		},
-		
-		/**
 		 * Executes or schedules for execution #doAjax()
 		 *
 		 * @param {Object} attrs - the Ajax request attributes configured at the server side
@@ -557,7 +532,6 @@
 
 			if (attrs.mp) { // multipart form. jQuery.ajax() doesn't help here ...
 				var ret = self.submitMultipartForm(context);
-				self._handleEventCancelation(attrs);
 				return ret;
 			}
 
@@ -665,8 +639,6 @@
 			self._executeHandlers(attrs.ah, attrs);
 			Wicket.Event.publish('/ajax/call/after', attrs);
 
-			self._handleEventCancelation(attrs);
-
 			return jqXHR;
 		},
 
@@ -1761,6 +1733,31 @@
 
 			Call: Wicket.Ajax.Call,
 
+			/**
+			 * Aborts the default event if attributes request it
+			 *
+			 * @param {Object} attrs - the Ajax request attributes configured at the server side
+			 */
+			_handleEventCancelation: function(attrs) {
+				var evt = attrs.event;
+				if (evt) {
+					if (!attrs.ad) {
+						try {
+							evt.preventDefault();
+						} catch (ignore) {
+							// WICKET-4986
+							// jquery fails 'member not found' with calls on busy channel
+						}
+					}
+
+					if (attrs.sp === "stop") {
+						Wicket.Event.stop(evt);
+					} else if (attrs.sp === "stopImmediate") {
+						Wicket.Event.stop(evt, true);
+					}
+				}
+			},
+
 			get: function (attrs) {
 
 				attrs.m = 'GET';
@@ -1800,10 +1797,12 @@
 							throttler.throttle(throttlingSettings.id, throttlingSettings.d,
 								Wicket.bind(function () {
 									call.ajax(attributes);
+									Wicket.Ajax._handleEventCancelation(attributes);
 								}, this));
 						}
 						else {
 							call.ajax(attributes);
+							Wicket.Ajax._handleEventCancelation(attributes);
 						}
 					});
 				});