[seam-commits] Seam SVN: r9869 - trunk/src/remoting/org/jboss/seam/remoting.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Jan 5 23:55:13 EST 2009
Author: shane.bryzak at jboss.com
Date: 2009-01-05 23:55:13 -0500 (Mon, 05 Jan 2009)
New Revision: 9869
Modified:
trunk/src/remoting/org/jboss/seam/remoting/remote.js
Log:
JBSEAM-3459
Modified: trunk/src/remoting/org/jboss/seam/remoting/remote.js
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/remote.js 2009-01-05 18:33:43 UTC (rev 9868)
+++ trunk/src/remoting/org/jboss/seam/remoting/remote.js 2009-01-06 04:55:13 UTC (rev 9869)
@@ -621,7 +621,7 @@
// Marshal the request
var envelope = Seam.Remoting.createEnvelope(Seam.Remoting.createHeader(), call.data);
Seam.Remoting.pendingCalls.put(call.id, call);
- call.asyncReq = Seam.Remoting.sendAjaxRequest(envelope, Seam.Remoting.PATH_EXECUTE, Seam.Remoting.processResponse, false);
+ Seam.Remoting.sendAjaxRequest(envelope, Seam.Remoting.PATH_EXECUTE, Seam.Remoting.processResponse, false);
}
return call;
@@ -633,7 +633,7 @@
if (!silent)
Seam.Remoting.displayLoadingMessage();
-
+
var asyncReq;
if (window.XMLHttpRequest)
@@ -643,15 +643,59 @@
asyncReq.overrideMimeType('text/xml');
}
else
+ {
asyncReq = new ActiveXObject("Microsoft.XMLHTTP");
+ }
- var rcb = Seam.Remoting.requestCallback;
+ asyncReq.onreadystatechange = function()
+ {
+ if (asyncReq.readyState == 4)
+ {
+ var inScope = typeof(Seam) == "undefined" ? false : true;
+
+ if (inScope) Seam.Remoting.hideLoadingMessage();
+
+ window.setTimeout(function() {
+ req.onreadystatechange = function() {};
+ }, 0);
- window.setTimeout(function() {
- asyncReq.onreadystatechange = function() {
- if (rcb) rcb(asyncReq, callback);
+ if (asyncReq.status == 200)
+ {
+ if (inScope) Seam.Remoting.log("Response packet:\n" + asyncReq.responseText);
+
+ if (callback)
+ {
+ // The following code deals with a Firefox security issue. It reparses the XML
+ // response if accessing the documentElement throws an exception
+ try
+ {
+ asyncReq.responseXML.documentElement;
+ Seam.Remoting.processResponse(asyncReq.responseXML);
+ }
+ catch (ex)
+ {
+ try
+ {
+ // Try it the IE way first...
+ var doc = new ActiveXObject("Microsoft.XMLDOM");
+ doc.async = "false";
+ doc.loadXML(asyncReq.responseText);
+ callback(doc);
+ }
+ catch (e)
+ {
+ // If that fails, use standards
+ var parser = new DOMParser();
+ Seam.Remoting.processResponse(parser.parseFromString(asyncReq.responseText, "text/xml"));
+ }
+ }
+ }
+ }
+ else
+ alert("There was an error processing your request. Error code: " + req.status);
}
- }, 0);
+
+ }
if (Seam.Remoting.encodedSessionId)
{
@@ -660,7 +704,6 @@
asyncReq.open("POST", Seam.Remoting.resourcePath + path, true);
asyncReq.send(envelope);
- return asyncReq;
}
Seam.Remoting.setCallback = function(component, methodName, callback)
@@ -668,55 +711,6 @@
component.__callback[methodName] = callback;
}
-Seam.Remoting.requestCallback = function(req, callback)
-{
- if (req.readyState == 4)
- {
- var inScope = typeof(Seam) == "undefined" ? false : true;
-
- if (inScope) Seam.Remoting.hideLoadingMessage();
-
- window.setTimeout(function() {
- req.onreadystatechange = function() {};
- }, 0);
-
- if (req.status == 200)
- {
- if (inScope) Seam.Remoting.log("Response packet:\n" + req.responseText);
-
- if (callback)
- {
- // The following code deals with a Firefox security issue. It reparses the XML
- // response if accessing the documentElement throws an exception
- try
- {
- req.responseXML.documentElement;
- callback(req.responseXML);
- }
- catch (ex)
- {
- try
- {
- // Try it the IE way first...
- var doc = new ActiveXObject("Microsoft.XMLDOM");
- doc.async = "false";
- doc.loadXML(req.responseText);
- callback(doc);
- }
- catch (e)
- {
- // If that fails, use standards
- var parser = new DOMParser();
- callback(parser.parseFromString(req.responseText, "text/xml"));
- }
- }
- }
- }
- else
- alert("There was an error processing your request. Error code: " + req.status);
- }
-}
-
Seam.Remoting.processResponse = function(doc)
{
var headerNode;
More information about the seam-commits
mailing list