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 2012/07/10 15:04:41 UTC

[1/3] git commit: WICKET-4649 Add an additional Ajax call listener point - before the call

Updated Branches:
  refs/heads/master 9f8af183e -> c8c8f502a


WICKET-4649 Add an additional Ajax call listener point - before the call

Add a test case for the 'before' handlers


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

Branch: refs/heads/master
Commit: c8c8f502a120ed97ec5d900fc3a1edc1a1b9e146
Parents: d228fcf
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Jul 10 16:03:59 2012 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Jul 10 16:03:59 2012 +0300

----------------------------------------------------------------------
 wicket-core/src/test/js/ajax.js |   38 ++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/c8c8f502/wicket-core/src/test/js/ajax.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/ajax.js b/wicket-core/src/test/js/ajax.js
index 23ae842..0f52461 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -689,5 +689,43 @@ jQuery(document).ready(function() {
 			target.off("event1");
 			jQuery(document).off();
 		});
+
+		/**
+		 * 'before' handlers are called even before preconditions
+		 * WICKET-4649
+		 */
+		asyncTest('before handler.', function () {
+
+			expect(3);
+
+			var attrs = {
+				u: 'data/ajax/nonExisting.json',
+				e: 'event1',
+				dt: 'json', // datatype
+				wr: false, // not Wicket's <ajax-response>
+				bh: [function(attributes) {
+					deepEqual(attrs, attributes, 'Before: attrs');
+				}],
+				pre: [function() {
+					ok(true, "Precondition is called!")
+					// do not allow calling of beforeSend handlers
+					return false;
+				}],
+				bsh: [function() {
+					ok(false, 'beforeSend handles should not be called');
+				}]
+			};
+
+			Wicket.Event.subscribe('/ajax/call/before', function(jqEvent, attributes) {
+				deepEqual(attrs, attributes, 'Global before: attrs');
+				start();
+			});
+
+			Wicket.Ajax.ajax(attrs);
+			var target = jQuery(window);
+			target.triggerHandler("event1");
+			target.off("event1");
+			jQuery(document).off();
+		});
 	}
 });