You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by kn...@apache.org on 2007/09/01 19:35:22 UTC
svn commit: r571833 -
/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
Author: knopp
Date: Sat Sep 1 10:35:21 2007
New Revision: 571833
URL: http://svn.apache.org/viewvc?rev=571833&view=rev
Log:
precondition fixes and lazy form serialization on ajax form submission
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=571833&r1=571832&r2=571833&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js Sat Sep 1 10:35:21 2007
@@ -53,12 +53,16 @@
// returns if the element belongs to current document
// if the argument is not element, function returns true
-Wicket.$$ = function(element) {
+Wicket.$$ = function(element) {
if (element == null || typeof(element) == "undefined" ||
- element.tagName == null || typeof(element.tagName)) {
+ element.tagName == null || typeof(element.tagName) == "undefined") {
return true;
- }
- return element.ownerDocument == document;
+ }
+
+ if (typeof(element.id) == "undefined" || element.id == null)
+ return element.ownerDocument == document;
+ else
+ return document.getElementById(element.id) == element;
}
Wicket.emptyFunction = function() { };
@@ -778,6 +782,7 @@
// The actual post implementation
doPost: function(body) {
+
if (this.precondition()) {
this.transport = Wicket.Ajax.getTransport();
@@ -788,6 +793,10 @@
var t = this.transport;
if (t != null) {
+ // we allow body to be a method - to lazily evaluate itself
+ if (typeof(body) == "function") {
+ body = body();
+ }
t.open("POST", url, this.async);
t.onreadystatechange = this.stateChangeCallback.bind(this);
t.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -936,9 +945,12 @@
// Submits a form using ajax.
// This method serializes a form and sends it as POST body.
submitForm: function(form, submitButton) {
- var body = Wicket.Form.serialize(form);
- if (submitButton != null) {
- body += Wicket.Form.encode(submitButton) + "=1";
+ var body = function() {
+ var s = Wicket.Form.serialize(form);
+ if (submitButton != null) {
+ s += Wicket.Form.encode(submitButton) + "=1";
+ }
+ return s;
}
return this.request.post(body);
},
@@ -1671,7 +1683,7 @@
function wicketAjaxPost(url, body, successHandler, failureHandler, precondition, channel) {
var call = new Wicket.Ajax.Call(url, successHandler, failureHandler, channel);
- if (typeof(precondition) != "undefined" && precondition != null) {
+ if (typeof(precondition) != "undefined" && precondition != null) {
call.request.precondition = precondition;
}
@@ -1854,4 +1866,3 @@
e.style.display = "none";
}
}
-