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 2011/04/12 17:07:51 UTC

svn commit: r1091444 - /wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Author: mgrigorov
Date: Tue Apr 12 15:07:51 2011
New Revision: 1091444

URL: http://svn.apache.org/viewvc?rev=1091444&view=rev
Log:
WICKET-3596 Problem with ajax requests in rc3 with browsers other than chrome

Strip the jsessionid before checking whether some resource is already contributed to the current page.


Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=1091444&r1=1091443&r2=1091444&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js Tue Apr 12 15:07:51 2011
@@ -1710,7 +1710,7 @@ Wicket.Head.addElement = function(elemen
 // is an element in head that is of same type as myElement, and whose src
 // attribute is same as myElement.src.
 Wicket.Head.containsElement = function(element, mandatoryAttribute) {
-	var attr = element.getAttribute(mandatoryAttribute);
+	var attr = Wicket.Head.stripJSessionId(element.getAttribute(mandatoryAttribute));
 	if (attr == null || attr == "" || typeof(attr) == "undefined")
 		return false;
 
@@ -1727,15 +1727,55 @@ Wicket.Head.containsElement = function(e
 		// check node names and mandatory attribute values
 		// we also have to check for attribute name that is suffixed by "_".
 		// this is necessary for filtering script references
-		if (node.tagName.toLowerCase() == element.tagName.toLowerCase() &&
-			(node.getAttribute(mandatoryAttribute) == attr ||
-		     node.getAttribute(mandatoryAttribute+"_") == attr)) {
-		    return true;
+		if (node.tagName.toLowerCase() == element.tagName.toLowerCase()) {
+		
+			var loadedUrl = Wicket.Head.stripJSessionId(node.getAttribute(mandatoryAttribute));
+			var loadedUrl_ = Wicket.Head.stripJSessionId(node.getAttribute(mandatoryAttribute+"_"));
+			if (loadedUrl == attr || loadedUrl_ == attr) {
+			    return true;
+			}
 		}
 	}
 	return false;
 }
 
+/**
+ * Removes the optional ';jsessionid=...' from the passed url
+ * 
+ * @param {String} url the url to strip the jsessionid from
+ * @return {String} the url without the jsessionid and its value
+ */
+// WICKET-3596
+Wicket.Head.stripJSessionId = function(url) {
+	if (url == null)
+	{
+		return null;
+	}
+
+	// http://.../abc;jsessionid=...?param=...
+	var ixSemiColon = url.indexOf(";");
+	if (ixSemiColon == -1)
+	{
+		return url;
+	}
+
+	var ixQuestionMark = url.indexOf("?");
+	if (ixQuestionMark == -1)
+	{
+		// no query paramaters; cut off at ";"
+		// http://.../abc;jsession=...
+		return url.substring(0, ixSemiColon);
+	}
+
+	if (ixQuestionMark <= ixSemiColon)
+	{
+		// ? is before ; - no jsessionid in the url
+		return url;
+	}
+
+	return url.substring(0, ixSemiColon) + url.substring(ixQuestionMark);
+}
+
 // Adds a javascript element to page header. 
 // The fakeSrc attribute is used to filter out duplicate javascript references.
 // External javascripts are loaded using xmlhttprequest. Then a javascript element is created and the