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/05/18 15:39:47 UTC
git commit: WICKET-4564 Use JsonFunction to deliver JSON with
function literals WICKET-4565 Unify the order of the parameters for the
JavaScript handlers
Updated Branches:
refs/heads/master 0c01d793f -> a1d5ef35b
WICKET-4564 Use JsonFunction to deliver JSON with function literals
WICKET-4565 Unify the order of the parameters for the JavaScript handlers
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/a1d5ef35
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/a1d5ef35
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/a1d5ef35
Branch: refs/heads/master
Commit: a1d5ef35b5167fffa2b7fb6ff718e72e2a29b431
Parents: 0c01d79
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri May 18 15:39:17 2012 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri May 18 15:39:17 2012 +0200
----------------------------------------------------------------------
.../wicket/ajax/AbstractDefaultAjaxBehavior.java | 37 ++++++--
.../org/apache/wicket/ajax/json/JsonFunction.java | 30 ++++++
.../main/java/org/apache/wicket/ajax/json/README | 4 +-
.../wicket/ajax/res/js/wicket-ajax-jquery.js | 61 ++++++-------
.../ajax/AbstractDefaultAjaxBehaviorTest.java | 71 +++++++++++++++
wicket-core/src/test/js/ajax.js | 52 ++++++------
6 files changed, 186 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/a1d5ef35/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 6d66697..895dac4 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
@@ -31,6 +31,7 @@ import org.apache.wicket.ajax.attributes.IAjaxCallListener;
import org.apache.wicket.ajax.attributes.ThrottlingSettings;
import org.apache.wicket.ajax.json.JSONException;
import org.apache.wicket.ajax.json.JSONObject;
+import org.apache.wicket.ajax.json.JsonFunction;
import org.apache.wicket.behavior.AbstractAjaxBehavior;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
@@ -60,6 +61,14 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior
public static final ResourceReference INDICATOR = new PackageResourceReference(
AbstractDefaultAjaxBehavior.class, "indicator.gif");
+ private static final String DYNAMIC_PARAMETER_FUNCTION_TEMPLATE = "function(){%s}";
+ private static final String PRECONDITION_FUNCTION_TEMPLATE = "function(attrs, jqXHR, settings){%s}";
+ private static final String COMPLETE_HANDLER_FUNCTION_TEMPLATE = "function(attrs, jqXHR, textStatus){%s}";
+ private static final String FAILURE_HANDLER_FUNCTION_TEMPLATE = "function(attrs, errorMessage){%s}";
+ private static final String SUCCESS_HANDLER_FUNCTION_TEMPLATE = "function(attrs, jqXHR, data, textStatus){%s}";
+ private static final String AFTER_HANDLER_FUNCTION_TEMPLATE = "function(attrs){%s}";
+ private static final String BEFORE_HANDLER_FUNCTION_TEMPLATE = "function(attrs, jqXHR, settings){%s}";
+
/**
* Subclasses should call super.onBind()
*
@@ -242,37 +251,49 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior
CharSequence beforeHandler = ajaxCallListener.getBeforeHandler(component);
if (Strings.isEmpty(beforeHandler) == false)
{
- attributesJson.append("bh", beforeHandler);
+ String func = String.format(BEFORE_HANDLER_FUNCTION_TEMPLATE, beforeHandler);
+ JsonFunction function = new JsonFunction(func);
+ attributesJson.append("bh", function);
}
CharSequence afterHandler = ajaxCallListener.getAfterHandler(component);
if (Strings.isEmpty(afterHandler) == false)
{
- attributesJson.append("ah", afterHandler);
+ String func = String.format(AFTER_HANDLER_FUNCTION_TEMPLATE, afterHandler);
+ JsonFunction function = new JsonFunction(func);
+ attributesJson.append("ah", function);
}
CharSequence successHandler = ajaxCallListener.getSuccessHandler(component);
if (Strings.isEmpty(successHandler) == false)
{
- attributesJson.append("sh", successHandler);
+ String func = String.format(SUCCESS_HANDLER_FUNCTION_TEMPLATE, successHandler);
+ JsonFunction function = new JsonFunction(func);
+ attributesJson.append("sh", function);
}
CharSequence failureHandler = ajaxCallListener.getFailureHandler(component);
if (Strings.isEmpty(failureHandler) == false)
{
- attributesJson.append("fh", failureHandler);
+ String func = String.format(FAILURE_HANDLER_FUNCTION_TEMPLATE, failureHandler);
+ JsonFunction function = new JsonFunction(func);
+ attributesJson.append("fh", function);
}
CharSequence completeHandler = ajaxCallListener.getCompleteHandler(component);
if (Strings.isEmpty(completeHandler) == false)
{
- attributesJson.append("coh", completeHandler);
+ String func = String.format(COMPLETE_HANDLER_FUNCTION_TEMPLATE, completeHandler);
+ JsonFunction function = new JsonFunction(func);
+ attributesJson.append("coh", function);
}
CharSequence precondition = ajaxCallListener.getPrecondition(component);
if (Strings.isEmpty(precondition) == false)
{
- attributesJson.append("pre", precondition);
+ String func = String.format(PRECONDITION_FUNCTION_TEMPLATE, precondition);
+ JsonFunction function = new JsonFunction(func);
+ attributesJson.append("pre", function);
}
}
}
@@ -298,7 +319,9 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior
{
for (CharSequence dynamicExtraParameter : dynamicExtraParameters)
{
- attributesJson.append("dep", dynamicExtraParameter);
+ String func = String.format(DYNAMIC_PARAMETER_FUNCTION_TEMPLATE, dynamicExtraParameter);
+ JsonFunction function = new JsonFunction(func);
+ attributesJson.append("dep", function);
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/a1d5ef35/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonFunction.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonFunction.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonFunction.java
new file mode 100644
index 0000000..355892a
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonFunction.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Igor Vaynberg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with
+ * the License. You may obtain a copy of the License in the LICENSE file, or at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.wicket.ajax.json;
+
+/**
+ * Represents a Json function. When written out these values are not escaped so its possible to write out raw
+ * JavaScript.
+ */
+public class JsonFunction implements JSONString {
+ private final CharSequence value;
+
+ public JsonFunction(CharSequence value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toJSONString() {
+ return value.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/a1d5ef35/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/README b/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
index 6a06271..c597817 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
@@ -1,2 +1,4 @@
These classes are copied from https://github.com/douglascrockford/JSON-java.
-Last update: May 18 2012
\ No newline at end of file
+Last update: May 18 2012
+
+Only JsonFunction is custom one. It is borrowed from https://github.com/ivaynberg/wicket-select2.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/a1d5ef35/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 463ff57..fa454de 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
@@ -364,22 +364,19 @@
* A helper function that executes an array of handlers (before, success, failure)
*
* @param {Array[FunctionBody]} handlers - the handlers to execute
- * @param {Array[String]} argumentNames - the names of the arguments which are passes to the handles
*/
- _executeHandlers: function (handlers, argumentNames) {
+ _executeHandlers: function (handlers) {
if (jQuery.isArray(handlers)) {
// cut the handlers argument
- var args = Array.prototype.slice.call(arguments).slice(2);
+ var args = Array.prototype.slice.call(arguments).slice(1);
for (var i = 0; i < handlers.length; i++) {
var handler = handlers[i];
if (jQuery.isFunction(handler)) {
handler.apply(this, args);
} else {
- var functionArgs = argumentNames;
- functionArgs.push(handler);
- Function.apply(this, functionArgs).apply(this, args);
+ new Function(handler).apply(this, args);
}
}
}
@@ -430,7 +427,7 @@
*/
doAjax: function (attrs) {
- var
+ var
// the headers to use for each Ajax request
headers = {
'Wicket-Ajax': 'true',
@@ -475,7 +472,7 @@
}
if (attrs.mp) { // multipart form. jQuery doesn't help here ...
- // TODO Wicket.next - should we execute all handlers ?!
+ // TODO Wicket.next - should we execute all handlers ?!
// Wicket 1.5 didn't support success/failure handlers for this, but we can do it
return this.submitMultipartForm(attrs);
}
@@ -500,7 +497,7 @@
// convert to URL encoded string
data = jQuery.param(data);
- // execute the request
+ // execute the request
var jqXHR = jQuery.ajax({
url: attrs.u,
type: attrs.m,
@@ -527,9 +524,7 @@
}
Wicket.Event.publish('/ajax/call/before', attrs, jqXHR, settings);
- self._executeHandlers(attrs.bh,
- ["attrs", "jqXHR", "settings"],
- attrs, jqXHR, settings);
+ self._executeHandlers(attrs.bh, attrs, jqXHR, settings);
if (attrs.i) {
// show the indicator
@@ -547,17 +542,15 @@
if (attrs.wr) {
self.processAjaxResponse(data, textStatus, jqXHR, attrs);
} else {
- self._executeHandlers(attrs.sh,
- ["data", "textStatus", "jqXHR", "attrs"],
- data, textStatus, jqXHR, attrs);
+ self._executeHandlers(attrs.sh, attrs, jqXHR, data, textStatus);
}
- Wicket.Event.publish('/ajax/call/success', data, textStatus, jqXHR, attrs);
+ Wicket.Event.publish('/ajax/call/success', attrs, jqXHR, data, textStatus);
},
- error: function(jqXHR, textStatus, errorThrown) {
+ error: function(jqXHR, textStatus, errorMessage) {
- self.failure(errorThrown, attrs, jqXHR, textStatus);
- Wicket.Event.publish('/ajax/call/failure', errorThrown, attrs, jqXHR, textStatus);
+ self.failure(attrs, jqXHR, errorMessage, textStatus);
+ Wicket.Event.publish('/ajax/call/failure', attrs, jqXHR, errorMessage, textStatus);
},
complete: function (jqXHR, textStatus) {
@@ -565,17 +558,15 @@
Wicket.DOM.hideIncrementally(attrs.i);
}
- self._executeHandlers(attrs.coh,
- ["jqXHR", "textStatus", "attrs"],
- jqXHR, textStatus, attrs);
- Wicket.Event.publish('/ajax/call/complete', jqXHR, textStatus, attrs);
+ self._executeHandlers(attrs.coh, attrs, jqXHR, textStatus);
+ Wicket.Event.publish('/ajax/call/complete', attrs, jqXHR, textStatus);
this.done();
}
});
// execute after handlers right after the Ajax request is fired
- self._executeHandlers(attrs.ah, ["attrs"], attrs);
+ self._executeHandlers(attrs.ah, attrs);
Wicket.Event.publish('/ajax/call/after', attrs);
if (!attrs.ad && attrs.event) {
@@ -830,7 +821,7 @@
var executer = new FunctionsExecuter(steps);
executer.start();
} catch (exception) {
- this.failure(exception, attrs);
+ this.failure(attrs, null, exception);
}
},
@@ -859,11 +850,11 @@
},
// On ajax request failure
- failure: function (message, attrs) {
- if (message) {
- Wicket.Log.error("Wicket.Ajax.Call.failure: Error while parsing response: " + message);
+ failure: function (attrs, jqXHR, errorMessage, textStatus) {
+ if (errorMessage) {
+ Wicket.Log.error("Wicket.Ajax.Call.failure: Error while parsing response: " + errorMessage);
}
- this._executeHandlers(attrs.fh, ["attrs"], attrs);
+ this._executeHandlers(attrs.fh, attrs, errorMessage);
},
done: function () {
@@ -1084,7 +1075,7 @@
/**
* Merges two objects. Values of the second will overwrite values of the first.
- *
+ *
* @param {Object} object1 - the first object to merge
* @param {Object} object2 - the second object to merge
* @return {Object} a new object with the values of object1 and object2
@@ -1092,10 +1083,10 @@
merge: function(object1, object2) {
return jQuery.extend({}, object1, object2);
},
-
+
/**
* Takes a function and returns a new one that will always have a particular context, i.e. 'this' will be the passed context.
- *
+ *
* @param {Function} fn - the function which context will be set
* @param {Object} context - the new context for the function
* @return {Function} the original function with the changed context
@@ -1164,7 +1155,7 @@
/**
* Serializes HTMLFormSelectElement to URL encoded key=value string.
*
- * @param {HTMLFormSelectElement} select - the form element to serialize
+ * @param {HTMLFormSelectElement} select - the form element to serialize
* @return an object of key -> value pair where 'value' can be an array of Strings if the select is .multiple,
* or empty object if the form element is disabled.
*/
@@ -1197,7 +1188,7 @@
*/
serializeInput: function (input) {
var result = [];
- if (input && input.type && !(input.type === 'image' || input.type === 'submit')) {
+ if (input && input.type && !(input.type === 'image' || input.type === 'submit')) {
var $input = jQuery(input);
result = $input.serializeArray();
}
@@ -1270,7 +1261,7 @@
serialize: function (element, dontTryToFindRootForm) {
if (typeof(element) === 'string') {
element = Wicket.$(element);
- }
+ }
if (element.tagName.toLowerCase() === "form") {
return Wicket.Form.serializeForm(element);
http://git-wip-us.apache.org/repos/asf/wicket/blob/a1d5ef35/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java
new file mode 100644
index 0000000..5c9487d
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.ajax;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.attributes.AjaxCallListener;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+/**
+ * Tests for AbstractDefaultAjaxBehavior
+ *
+ * @since 6.0
+ */
+public class AbstractDefaultAjaxBehaviorTest extends Assert
+{
+ /**
+ * Checks the generated JSON for Ajax's attributes
+ */
+ @Test
+ public void renderAjaxAttributes()
+ {
+ AjaxRequestAttributes attributes = new AjaxRequestAttributes();
+
+ AjaxCallListener listener = new AjaxCallListener();
+ listener.onPrecondition("return somePrecondition();");
+ listener.onBefore("alert('Before!');");
+ listener.onAfter("alert('After!');");
+ listener.onSuccess("alert('Success!');");
+ listener.onFailure("alert('Failure!');");
+ listener.onComplete("alert('Complete!');");
+ attributes.getAjaxCallListeners().add(listener);
+
+ Component component = Mockito.mock(Component.class);
+ AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior()
+ {
+ @Override
+ protected void respond(AjaxRequestTarget target)
+ {
+ }
+
+ @Override
+ public CharSequence getCallbackUrl()
+ {
+ return "some/url";
+ }
+ };
+ behavior.bind(component);
+
+ CharSequence json = behavior.renderAjaxAttributes(component, attributes);
+
+ String expected = "{\"coh\":[function(attrs, jqXHR, textStatus){alert('Complete!');}],\"u\":\"some/url\",\"pre\":[function(attrs, jqXHR, settings){return somePrecondition();}],\"fh\":[function(attrs, errorMessage){alert('Failure!');}],\"bh\":[function(attrs, jqXHR, settings){alert('Before!');}],\"sh\":[function(attrs, jqXHR, data, textStatus){alert('Success!');}],\"ah\":[function(attrs){alert('After!');}]}";
+ assertEquals(expected, json);
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/a1d5ef35/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 e12672f..6df8a00 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -38,7 +38,7 @@
jQuery(document).ready(function() {
execute = function (attributes) {
-
+
var defaults = {
fh: [
function () {
@@ -196,7 +196,7 @@ jQuery(document).ready(function() {
dt: 'json', // datatype
wr: false, // not Wicket's <ajax-response>
sh: [
- function(data, textStatus, jqXHR) {
+ function(attributes, jqXHR, data, textStatus) {
start();
var expected = {
one: 1,
@@ -223,7 +223,7 @@ jQuery(document).ready(function() {
dt: 'json', // datatype
wr: false, // not Wicket's <ajax-response>
sh: [
- function(data, textStatus, jqXHR) {
+ function(attributes, jqXHR, data, textStatus) {
var expected = {
one: 1,
two: '2',
@@ -263,7 +263,7 @@ jQuery(document).ready(function() {
dt: 'json', // datatype
wr: false, // not Wicket's <ajax-response>
sh: [
- function(data, textStatus, jqXHR) {
+ function(attributes, jqXHR, data, textStatus) {
start();
var expected = {
one: 1,
@@ -299,41 +299,41 @@ jQuery(document).ready(function() {
dt: 'json', // datatype
wr: false, // not Wicket's <ajax-response>
sh: [
- function(data, textStatus, jqXHR, attributes) {
+ function(attributes, jqXHR, data, textStatus) {
start();
var expected = {
one: 1,
two: '2',
three: true
};
- deepEqual(data, expected);
- equal('success', textStatus);
- deepEqual(attrs, attributes);
- ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Assert that jqXHR is a XMLHttpRequest');
+ deepEqual(data, expected, 'Success: data deep equal');
+ equal('success', textStatus, 'Success: textStatus');
+ deepEqual(attrs, attributes, 'Success: attributes deep equal');
+ ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Success: Assert that jqXHR is a XMLHttpRequest');
}
],
fh: [
- function(attributes) {
+ function(attributes, errorMessage) {
ok(false, 'Should not be called');
}
],
bh: [
function(attributes, jqXHR, settings) {
- deepEqual(attrs, attributes);
- ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Assert that jqXHR is a XMLHttpRequest');
- ok(jQuery.isFunction(settings.beforeSend), 'Assert that settings is the object passed to jQuery.ajax()');
+ deepEqual(attrs, attributes, 'Before: attributes deep equal');
+ ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Before: Assert that jqXHR is a XMLHttpRequest');
+ ok(jQuery.isFunction(settings.beforeSend), 'Before: Assert that settings is the object passed to jQuery.ajax()');
}
],
ah: [
function(attributes) {
- deepEqual(attrs, attributes);
+ deepEqual(attrs, attributes, 'After: attributes deep equal');
}
],
coh: [
- function(jqXHR, textStatus, attributes) {
- ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Assert that jqXHR is a XMLHttpRequest');
- equal('success', textStatus);
- deepEqual(attrs, attributes);
+ function(attributes, jqXHR, textStatus) {
+ ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Complete: Assert that jqXHR is a XMLHttpRequest');
+ equal('success', textStatus, 'Complete: textStatus');
+ deepEqual(attrs, attributes, 'Complete: attributes deep equal');
}
]
}
@@ -355,7 +355,7 @@ jQuery(document).ready(function() {
dt: 'json', // datatype
wr: false, // not Wicket's <ajax-response>
sh: [
- function(data, textStatus, jqXHR, attributes) {
+ function(attributes, jqXHR, data, textStatus) {
ok(false, 'Should not be called');
}
],
@@ -378,7 +378,7 @@ jQuery(document).ready(function() {
}
],
coh: [
- function(jqXHR, textStatus, attributes) {
+ function(attributes, jqXHR, textStatus) {
ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Assert that jqXHR is a XMLHttpRequest');
equal('error', textStatus);
deepEqual(attrs, attributes);
@@ -404,7 +404,7 @@ jQuery(document).ready(function() {
var attrs = {
u: 'data/ajax/nonWicketResponse.json',
coh: [
- function(jqXHR, textStatus, attributes) {
+ function(attributes, jqXHR, textStatus) {
start();
equal(textStatus, "parsererror", "textStatus")
equal(attributes.u, attrs.u, "url");
@@ -448,7 +448,7 @@ jQuery(document).ready(function() {
wr: false // not Wicket's <ajax-response>
};
- Wicket.Event.subscribe('/ajax/call/success', function(jqEvent, data, textStatus, jqXHR, attributes) {
+ Wicket.Event.subscribe('/ajax/call/success', function(jqEvent, attributes, jqXHR, data, textStatus) {
start();
var expected = {
one: 1,
@@ -475,7 +475,7 @@ jQuery(document).ready(function() {
deepEqual(attrs, attributes, 'After: attrs');
});
- Wicket.Event.subscribe('/ajax/call/complete', function(jqEvent, jqXHR, textStatus, attributes) {
+ Wicket.Event.subscribe('/ajax/call/complete', function(jqEvent, attributes, jqXHR, textStatus) {
ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Complete: Assert that jqXHR is a XMLHttpRequest');
equal('success', textStatus, 'Complete: textStatus');
deepEqual(attrs, attributes, 'Complete: attrs');
@@ -502,11 +502,11 @@ jQuery(document).ready(function() {
wr: false // not Wicket's <ajax-response>
};
- Wicket.Event.subscribe('/ajax/call/success', function(jqEvent, data, textStatus, jqXHR, attributes) {
+ Wicket.Event.subscribe('/ajax/call/success', function(jqEvent, attributes, jqXHR, data, textStatus) {
ok(false, 'Success handles should not be called');
});
- Wicket.Event.subscribe('/ajax/call/failure', function(jqEvent, errorThrown, attributes, jqXHR, textStatus) {
+ Wicket.Event.subscribe('/ajax/call/failure', function(jqEvent, attributes, jqXHR, errorThrown, textStatus) {
start();
equal('Not Found', errorThrown, 'Failure: errorThrown');
ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Failure: Assert that jqXHR is a XMLHttpRequest');
@@ -524,7 +524,7 @@ jQuery(document).ready(function() {
deepEqual(attrs, attributes, 'After: attrs');
});
- Wicket.Event.subscribe('/ajax/call/complete', function(jqEvent, jqXHR, textStatus, attributes) {
+ Wicket.Event.subscribe('/ajax/call/complete', function(jqEvent, attributes, jqXHR, textStatus) {
ok(jQuery.isFunction(jqXHR.getResponseHeader), 'Complete: Assert that jqXHR is a XMLHttpRequest');
equal('error', textStatus, 'Complete: textStatus');
deepEqual(attrs, attributes, 'Complete: attrs');