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/08/07 11:52:35 UTC
[1/2] git commit: WICKET-5306 Dynamic extra paramaters not evaluated
in ajax submitting behavior in a multipart form
Updated Branches:
refs/heads/master ad53a1bc3 -> c276f09cc
WICKET-5306 Dynamic extra paramaters not evaluated in ajax submitting behavior in a multipart form
Add unit tests that dynamic extra parameters are calculated for multipart form submits
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/7d22d55d
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/7d22d55d
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/7d22d55d
Branch: refs/heads/master
Commit: 7d22d55d77abbcc853ea93c0baf86df1c1fb333c
Parents: ad53a1b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Aug 7 11:04:17 2013 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Wed Aug 7 11:04:17 2013 +0200
----------------------------------------------------------------------
wicket-core/src/test/js/ajax.js | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/7d22d55d/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 da30d7e..d370de8 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -990,7 +990,7 @@ jQuery(document).ready(function() {
*/
asyncTest('Submit nested form - success scenario.', function () {
- expect(8);
+ expect(9);
var attrs = {
f: "innerForm", // the id of the form to submit
@@ -1012,6 +1012,13 @@ jQuery(document).ready(function() {
equal(attrs.event.isDefaultPrevented(), false, "default behavior is allowed");
}
]
+ ,
+ dep: [
+ function(attrs) {
+ ok(true, "Dynamic parameters are collected in success scenario!");
+ return { 'one': 1 };
+ }
+ ]
};
Wicket.Ajax.ajax(attrs);
@@ -1026,7 +1033,7 @@ jQuery(document).ready(function() {
*/
asyncTest('Submit nested form - failure scenario.', function () {
- expect(7);
+ expect(8);
var attrs = {
f: "innerForm", // the id of the form to submit
@@ -1047,6 +1054,12 @@ jQuery(document).ready(function() {
ok(true, "Complete handler executed");
equal(attrs.event.isDefaultPrevented(), false, "default behavior is not prevented");
}
+ ],
+ dep: [
+ function(attrs) {
+ ok(true, "Dynamic parameters are collected in failure scenario!");
+ return { 'one': 1 };
+ }
]
};
[2/2] git commit: WICKET-5306 Dynamic and static extra paramaters not
evaluated in ajax submitting behavior in a multipart form
Posted by mg...@apache.org.
WICKET-5306 Dynamic and static extra paramaters not evaluated in ajax submitting behavior in a multipart form
Use static extra parameters when submitting multipart form
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/c276f09c
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c276f09c
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c276f09c
Branch: refs/heads/master
Commit: c276f09cc71747c28b17093bc98f6c5a62b5ad85
Parents: 7d22d55
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Aug 7 11:51:24 2013 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Wed Aug 7 11:51:24 2013 +0200
----------------------------------------------------------------------
.../wicket/ajax/res/js/wicket-ajax-jquery.js | 14 ++++-
wicket-core/src/test/js/ajax.js | 55 ++++++++++++++++----
2 files changed, 57 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/c276f09c/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 b584861..44719fe 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
@@ -803,12 +803,24 @@
form.target = iframe.name;
var separator = (attrs.u.indexOf("?")>-1 ? "&" : "?");
form.action = attrs.u + separator + "wicket-ajax=true&wicket-ajax-baseurl=" + Wicket.Form.encode(getAjaxBaseUrl());
+
+ // add the static extra parameters
+ if (attrs.ep) {
+ var extraParametersArray = this._asParamArray(attrs.ep);
+ if (extraParametersArray.length > 0) {
+ var extraParametersQueryString = jQuery.param(extraParametersArray);
+ form.action = form.action + '&' + extraParametersQueryString;
+ }
+ }
+
+ // add the dynamic extra parameters
if (jQuery.isArray(attrs.dep)) {
var dynamicExtraParameters = this._calculateDynamicParameters(attrs);
if (dynamicExtraParameters) {
form.action = form.action + '&' + dynamicExtraParameters;
}
}
+
form.method = "post";
form.enctype = "multipart/form-data";
form.encoding = "multipart/form-data";
@@ -826,7 +838,7 @@
// show the indicator
Wicket.DOM.showIncrementally(attrs.i);
}
-
+
//submit the form into the iframe, response will be handled by the onload callback
form.submit();
http://git-wip-us.apache.org/repos/asf/wicket/blob/c276f09c/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 d370de8..b42c5a8 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -990,7 +990,7 @@ jQuery(document).ready(function() {
*/
asyncTest('Submit nested form - success scenario.', function () {
- expect(9);
+ expect(13);
var attrs = {
f: "innerForm", // the id of the form to submit
@@ -1002,7 +1002,21 @@ jQuery(document).ready(function() {
ad: true, // do not allow default behavior
bh: [ function(attrs) { ok(true, "Before handler executed"); } ],
pre: [ function(attrs) {ok(true, "Precondition executed"); return true; } ],
- bsh: [ function(attrs) { ok(true, "BeforeSend handler executed"); } ],
+ bsh: [ function(attrs) {
+ ok(true, "BeforeSend handler executed");
+
+ var form = Wicket.$(attrs.f);
+ if (form.tagName.toLowerCase() !== "form") {
+ do {
+ form = form.parentNode;
+ } while(form.tagName.toLowerCase() !== "form" && form !== document.body);
+ }
+ var formUrl = form.action;
+ ok(formUrl.indexOf('dynamicEPName') > -1, "Dynamic extra parameter name is in the request query string");
+ ok(formUrl.indexOf('dynamicEPValue') > -1, "Dynamic extra parameter value is in the request query string");
+ ok(formUrl.indexOf('extraParamName') > -1, "Static extra parameter name is in the request query string");
+ ok(formUrl.indexOf('extraParamValue') > -1, "Static extra parameter value is in the request query string");
+ } ],
ah: [ function(attrs) { ok(true, "After handler executed"); } ],
sh: [ function(attrs) { ok(true, "Success handler executed"); } ],
fh: [ function(attrs) { ok(false, "Failure handler should not be executed"); } ],
@@ -1011,14 +1025,16 @@ jQuery(document).ready(function() {
ok(true, "Complete handler executed");
equal(attrs.event.isDefaultPrevented(), false, "default behavior is allowed");
}
- ]
- ,
+ ],
dep: [
function(attrs) {
ok(true, "Dynamic parameters are collected in success scenario!");
- return { 'one': 1 };
+ return { 'dynamicEPName': 'dynamicEPValue' };
}
- ]
+ ],
+ ep: {
+ 'extraParamName': 'extraParamValue'
+ }
};
Wicket.Ajax.ajax(attrs);
@@ -1033,7 +1049,7 @@ jQuery(document).ready(function() {
*/
asyncTest('Submit nested form - failure scenario.', function () {
- expect(8);
+ expect(12);
var attrs = {
f: "innerForm", // the id of the form to submit
@@ -1045,7 +1061,21 @@ jQuery(document).ready(function() {
ad: false,
bh: [ function(attrs) { ok(true, "Before handler executed"); } ],
pre: [ function(attrs) {ok(true, "Precondition executed"); return true; } ],
- bsh: [ function(attrs) { ok(true, "BeforeSend handler executed"); } ],
+ bsh: [ function(attrs) {
+ ok(true, "BeforeSend handler executed");
+
+ var form = Wicket.$(attrs.f);
+ if (form.tagName.toLowerCase() !== "form") {
+ do {
+ form = form.parentNode;
+ } while(form.tagName.toLowerCase() !== "form" && form !== document.body);
+ }
+ var formUrl = form.action;
+ ok(formUrl.indexOf('dynamicEPName') > -1, "Dynamic extra parameter name is in the request query string");
+ ok(formUrl.indexOf('dynamicEPValue') > -1, "Dynamic extra parameter value is in the request query string");
+ ok(formUrl.indexOf('extraParamName') > -1, "Static extra parameter name is in the request query string");
+ ok(formUrl.indexOf('extraParamValue') > -1, "Static extra parameter value is in the request query string");
+ } ],
ah: [ function(attrs) { ok(true, "After handler executed"); } ],
sh: [ function(attrs) { ok(false, "Success handler should not be executed"); } ],
fh: [ function(attrs) { ok(true, "Failure handler executed"); start(); } ],
@@ -1057,10 +1087,13 @@ jQuery(document).ready(function() {
],
dep: [
function(attrs) {
- ok(true, "Dynamic parameters are collected in failure scenario!");
- return { 'one': 1 };
+ ok(true, "Dynamic parameters are collected in success scenario!");
+ return { 'dynamicEPName': 'dynamicEPValue' };
}
- ]
+ ],
+ ep: {
+ 'extraParamName': 'extraParamValue'
+ }
};
Wicket.Ajax.ajax(attrs);