You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2015/07/08 15:25:50 UTC

wicket git commit: test for ajax init and done

Repository: wicket
Updated Branches:
  refs/heads/master e08754c49 -> 5c2814bff


test for ajax init and done


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

Branch: refs/heads/master
Commit: 5c2814bff470ecae5d734b11749b179a2a4af462
Parents: e08754c
Author: Sven Meier <sv...@apache.org>
Authored: Wed Jul 8 15:23:32 2015 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Wed Jul 8 15:23:32 2015 +0200

----------------------------------------------------------------------
 wicket-core/src/test/js/ajax.js                 | 56 +++++++++++++++++---
 .../src/docs/guide/ajax/ajax_6.gdoc             |  2 +
 2 files changed, 50 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/5c2814bf/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 9adf553..da69152 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -31,6 +31,11 @@
 
 		 </Directory>
 
+	... or tweak wicket-examples' StartExamples.java like so:
+
+		bb.setContextPath("/ajax-tests");
+		bb.setWar("../wicket-core/src");
+
 	then run it by opening "http://localhost/ajax-tests/test/js/all.html" in the browser
 
  */
@@ -430,7 +435,7 @@ jQuery(document).ready(function() {
 		 */
 		asyncTest('verify default attributes.', function () {
 
-			expect(24);
+			expect(25);
 
 			var attrs = {
 				u: 'data/ajax/nonWicketResponse.json',
@@ -456,6 +461,7 @@ jQuery(document).ready(function() {
 						ok(attributes.sh === undefined, 'success handlers');
 						ok(attributes.fh === undefined, 'failure handlers');
 						deepEqual(attrs.coh, attributes.coh, 'complete handlers');
+						ok(attributes.dh === undefined, 'done handlers');
 						ok(attributes.ep === undefined, 'extra parameters');
 						ok(attributes.dep === undefined, 'dynamic extra parameters');
 						equal(attributes.async, true, 'asynchronous');
@@ -470,7 +476,7 @@ jQuery(document).ready(function() {
 
 		asyncTest('verify arguments to global listeners. Success scenario.', function () {
 
-			expect(11);
+			expect(13);
 
 			var attrs = {
 				u: 'data/ajax/nonWicketResponse.json',
@@ -479,6 +485,10 @@ jQuery(document).ready(function() {
 				wr: false // not Wicket's <ajax-response>
 			};
 
+			Wicket.Event.subscribe('/ajax/call/init', function(jqEvent, attributes) {
+				equal(attrs.u, attributes.u, 'Complete: attrs');
+			});
+
 			Wicket.Event.subscribe('/ajax/call/success', function(jqEvent, attributes, jqXHR, data, textStatus) {
 				start();
 				var expected = {
@@ -510,6 +520,10 @@ jQuery(document).ready(function() {
 				ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Complete: Assert that jqXHR is a XMLHttpRequest');
 				equal('success', textStatus, 'Complete: textStatus');
 				equal(attrs.u, attributes.u, 'Complete: attrs');
+			});
+
+			Wicket.Event.subscribe('/ajax/call/done', function(jqEvent, attributes) {
+				equal(attrs.u, attributes.u, 'Done: attrs');
 
 				// unregister all subscribers
 				Wicket.Event.unsubscribe();
@@ -524,7 +538,7 @@ jQuery(document).ready(function() {
 
 		asyncTest('verify arguments to global listeners. Failure scenario.', function () {
 
-			expect(11);
+			expect(13);
 
 			var attrs = {
 				u: 'data/ajax/nonExisting.json',
@@ -533,6 +547,10 @@ jQuery(document).ready(function() {
 				wr: false // not Wicket's <ajax-response>
 			};
 
+			Wicket.Event.subscribe('/ajax/call/init', function(jqEvent, attributes) {
+				equal(attrs.u, attributes.u, 'Complete: attrs');
+			});
+
 			Wicket.Event.subscribe('/ajax/call/success', function(jqEvent, attributes, jqXHR, data, textStatus) {
 				ok(false, 'Success handles should not be called');
 			});
@@ -559,6 +577,10 @@ jQuery(document).ready(function() {
 				ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Complete: Assert that jqXHR is a XMLHttpRequest');
 				equal('error', textStatus, 'Complete: textStatus');
 				equal(attrs.u, attributes.u, 'Complete: attrs');
+			});
+
+			Wicket.Event.subscribe('/ajax/call/done', function(jqEvent, attributes) {
+				equal(attrs.u, attributes.u, 'Complete: attrs');
 
 				// unregister all subscribers
 				Wicket.Event.unsubscribe();
@@ -747,18 +769,18 @@ jQuery(document).ready(function() {
 
 		/**
 		 * Verifies the order of execution of the callbacks.
-		 * The order must be: before, precondition, beforeSend, after, success, complete.
+		 * The order must be: before, precondition, beforeSend, after, success, complete, done.
 		 * Three consecutive executions are made on the same Ajax channel validating
 		 * that they do not overlap.
 		 */
 		asyncTest('callbacks order - success scenario.', function () {
 
-			expect(36);
+			expect(42);
 
 			var order = 0,
 
 			// the number of assertions per iteration
-			numberOfTests = 12,
+			numberOfTests = 14,
 
 			// calculates the offset for the order depending on the execution number
 			offset = function(extraData) {
@@ -803,6 +825,11 @@ jQuery(document).ready(function() {
 					function(attrs) {
 						equal((11 + offset(attrs.event.extraData)), ++order, "Complete handler");
 					}
+				],
+				dh: [
+					function(attrs) {
+						equal((13 + offset(attrs.event.extraData)), ++order, "Done handler");
+					}
 				]
 			};
 
@@ -834,6 +861,10 @@ jQuery(document).ready(function() {
 
 			Wicket.Event.subscribe('/ajax/call/complete', function(jqEvent, attrs) {
 				equal((12 + offset(attrs.event.extraData)), ++order, "Global complete handler");
+			});
+
+			Wicket.Event.subscribe('/ajax/call/done', function(jqEvent, attrs) {
+				equal((14 + offset(attrs.event.extraData)), ++order, "Global done handler");
 
 				if (attrs.event.extraData.round === 2) {
 					// unregister all global subscribers
@@ -860,12 +891,12 @@ jQuery(document).ready(function() {
 		 */
 		asyncTest('callbacks order - failure scenario.', function () {
 
-			expect(36);
+			expect(42);
 
 			var order = 0,
 
 			// the number of assertions per iteration
-			numberOfTests = 12,
+			numberOfTests = 14,
 
 			// calculates the offset for the order depending on the execution number
 			offset = function(extraData) {
@@ -910,6 +941,11 @@ jQuery(document).ready(function() {
 					function(attrs) {
 						equal((11 + offset(attrs.event.extraData)), ++order, "Complete handler");
 					}
+				],
+				dh: [
+					function(attrs) {
+						equal((13 + offset(attrs.event.extraData)), ++order, "Done handler");
+					}
 				]
 			};
 
@@ -941,6 +977,10 @@ jQuery(document).ready(function() {
 
 			Wicket.Event.subscribe('/ajax/call/complete', function(jqEvent, attrs) {
 				equal((12 + offset(attrs.event.extraData)), ++order, "Global complete handler");
+			});
+
+			Wicket.Event.subscribe('/ajax/call/done', function(jqEvent, attrs) {
+				equal((14 + offset(attrs.event.extraData)), ++order, "Global done handler");
 
 				if (attrs.event.extraData.round === 2) {
 					// unregister all global subscribers

http://git-wip-us.apache.org/repos/asf/wicket/blob/5c2814bf/wicket-user-guide/src/docs/guide/ajax/ajax_6.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/ajax/ajax_6.gdoc b/wicket-user-guide/src/docs/guide/ajax/ajax_6.gdoc
index 4fcf114..92ac37f 100644
--- a/wicket-user-guide/src/docs/guide/ajax/ajax_6.gdoc
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_6.gdoc
@@ -141,12 +141,14 @@ So far we have seen how to use an AJAX call listener to track the AJAX activity
 
 Global AJAX call events are handled with JavaScript. We can register a callback function for a specific event of the AJAX call lifecycle with function @Wicket.Event.subscribe('<eventName>', <callback Function>)@. The first parameter of this function is the name of the event we want to handle. The possible names are:
 
+* '/ajax/call/init': called on initialization of an ajax call
 * '/ajax/call/before': called before any other event handler.
 * '/ajax/call/beforeSend': called just before the AJAX call.
 * '/ajax/call/after': called after the AJAX request has been sent.
 * '/ajax/call/success': called if the AJAX call has successfully returned.
 * '/ajax/call/failure': called if the AJAX call has returned with a failure.
 * '/ajax/call/complete': called when the AJAX call has completed.
+* '/ajax/call/done': called when the AJAX call is done.
 * '/dom/node/removing': called when a component is about to be removed via AJAX. This  happens when component markup is updated via AJAX (i.e. the component itself or one of its containers has been added to @AjaxRequestTarget@) 
 * '/dom/node/added': called when a component has been added via AJAX. Just like '/dom/node/removing', this event is triggered when a component is added to @AjaxRequestTarget@.