Update of /cvsroot/qooxdoo/qooxdoo/source/script/binding
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15829/source/script/binding
Modified Files:
Tag: renderer
QxFrameTransport.js QxTransport.js QxXmlHttpTransport.js
Log Message:
First updates to new AJAX layer
Index: QxFrameTransport.js
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/binding/Attic/QxFrameTransport.js,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** QxFrameTransport.js 18 Jan 2006 10:38:18 -0000 1.1.2.1
--- QxFrameTransport.js 18 Jan 2006 12:23:40 -0000 1.1.2.2
***************
*** 41,42 ****
--- 41,46 ----
// the real availability check (activeX stuff and so on) follows at the first real request
QxTransport.registerType(QxFrameTransport, "QxFrameTransport");
+
+ QxFrameTransport.isSupported = function() {
+ return true;
+ };
\ No newline at end of file
Index: QxTransport.js
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/binding/Attic/QxTransport.js,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** QxTransport.js 18 Jan 2006 10:38:18 -0000 1.1.2.1
--- QxTransport.js 18 Jan 2006 12:23:40 -0000 1.1.2.2
***************
*** 91,95 ****
QxTransport.TYPES_CHECKED = true;
! if (QxTransport.SUPPORTED_TYPES) {
throw new Error("No supported transport types were found!");
};
--- 91,95 ----
QxTransport.TYPES_CHECKED = true;
! if (QxUtil.isObjectEmpty(QxTransport.SUPPORTED_TYPES)) {
throw new Error("No supported transport types were found!");
};
Index: QxXmlHttpTransport.js
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/binding/Attic/QxXmlHttpTransport.js,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** QxXmlHttpTransport.js 18 Jan 2006 10:38:18 -0000 1.1.2.1
--- QxXmlHttpTransport.js 18 Jan 2006 12:23:40 -0000 1.1.2.2
***************
*** 33,37 ****
{
QxTarget.call(this);
!
};
--- 33,38 ----
{
QxTarget.call(this);
!
! this._req = QxXmlHttpTransport.CREATE_REQUEST();
};
***************
*** 41,42 ****
--- 42,489 ----
// the real availability check (activeX stuff and so on) follows at the first real request
QxTransport.registerType(QxXmlHttpTransport, "QxXmlHttpTransport");
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ GLOBAL METHOD DETECTION
+ ---------------------------------------------------------------------------
+ */
+
+ QxXmlHttpTransport.isSupported = function()
+ {
+ if (window.XMLHttpRequest)
+ {
+ QxXmlHttpTransport.createRequestObject = QxXmlHttpTransport.createNativeRequestObject;
+ return true;
+ };
+
+ if (window.ActiveXObject)
+ {
+ var vServers = [ "Microsoft.XMLHTTP", "MSXML.XMLHTTP", "MSXML2.XMLHTTP", "MSXML3.XMLHTTP", "MSXML4.XMLHTTP" ];
+ var vObject;
+
+ for (var i=0, l=vServers.length; i<l; i++)
+ {
+ try
+ {
+ vObject = new ActiveXObject(servers[i]);
+ break;
+ }
+ catch(ex) {};
+ };
+
+ if (vObject)
+ {
+ QxXmlHttpTransport.activeXServer = servers[i];
+ QxXmlHttpTransport.createRequestObject = QxXmlHttpTransport.createActiveXRequestObject;
+
+ return true;
+ };
+ };
+
+ return false;
+ };
+
+ QxXmlHttpTransport.createRequestObject = function() {
+ throw new Error("XMLHTTP is not supported!");
+ };
+
+
+ QxXmlHttpTransport.createNativeRequestObject = function() {
+ return new XMLHttpRequest;
+ };
+
+ QxXmlHttpTransport.createActiveXRequestObject = function() {
+ return new ActiveXObject(QxXmlHttpTransport.activeXServer);
+ };
+
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ PROPERTIES
+ ---------------------------------------------------------------------------
+ */
+
+ /*!
+ Determines what type of request to issue
+ */
+ QxXmlHttpTransport.addProperty({name : "requestMethod", type : QxConst.TYPEOF_STRING, defaultValue: "post" });
+
+ /*!
+ Set the request to asynchronous
+ */
+ QxXmlHttpTransport.addProperty({name : "async", type : QxConst.TYPEOF_BOOLEAN, defaultValue: true });
+
+ /*!
+ Set the payload to be sent via this request
+ */
+ QxXmlHttpTransport.addProperty({name : "payload", type : QxConst.TYPEOF_STRING });
+
+ /*!
+ Gives the size of the response
+ FIXME - This property can be set publicly - definitely not what we want
+ */
+ QxXmlHttpTransport.addProperty({name : "responseSize", type: QxConst.TYPEOF_NUMBER, defaultValue : -1 });
+
+ /*!
+ URL to issue the request to
+ */
+ QxXmlHttpTransport.addProperty({name : "target", type: QxConst.TYPEOF_STRING });
+
+ /*!
+ Username to use for HTTP authentication
+ */
+ QxXmlHttpTransport.addProperty({name : "username", type: QxConst.TYPEOF_STRING });
+
+ /*!
+ Password to use for HTTP authentication
+ */
+ QxXmlHttpTransport.addProperty({name : "password", type: QxConst.TYPEOF_STRING });
+
+
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ DATA
+ ---------------------------------------------------------------------------
+ */
+
+ // DISUSS: Why do we need both (wpbasti)
+
+ /*!
+ _requestTypes - Array of request types that are valid
+ */
+ QxXmlHttpTransport._requestTypes = [ "GET", "POST", "HEAD" ];
+
+ /*!
+ Symbolic constants for public use
+ */
+ QxXmlHttpTransport.RequestTypes = {
+ GET : "GET",
+ POST : "POST",
+ HEAD : "HEAD"
+ };
+
+
+
+
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ METHODS
+ ---------------------------------------------------------------------------
+ */
+
+ /*!
+ Check to ensure that only valid request methods are requested
+ */
+ proto._checkRequestMethod = function(propValue, propData) {
+ return QxXmlHttpTransport._requestTypes.contains(propValue);
+ };
+
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ REQUEST HEADER SUPPORT
+ ---------------------------------------------------------------------------
+ */
+
+ /*!
+ Adds a request header to the request
+ */
+ proto.setRequestHeader = function(headerName, headerValue) {
+ this._requestHeaders[headerName] = headerValue;
+ };
+
+ /*!
+ Returns the current value of the header with the provided name, and null if no such header is currently set.
+ */
+ proto.getRequestHeader = function(headerName) {
+ return this._requestHeaders[headerName] || null;
+ };
+
+ /*!
+ Provides an array of currently set request headers.
+ */
+ proto.getRequestHeaders = function() {
+ return this._requestHeaders;
+ };
+
+ /*!
+ Removes the request header of the given name from this request. Returns true in all cases.
+ */
+ proto.removeRequestHeader = function(headerName)
+ {
+ delete this._requestHeaders[headerName];
+ return true;
+ };
+
+ /*!
+ Deletes all request headers from the current object.
+ */
+ proto.removeRequestHeaders = function()
+ {
+ // unneeded?
+ // delete this._requestHeaders;
+
+ this._requestHeaders = {};
+ return true;
+ };
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ RESPONSE HEADER SUPPORT
+ ---------------------------------------------------------------------------
+ */
+
+ /*!
+ Returns a specific header provided by the server upon sending a request,
+ with header name determined by the argument headerName.
+
+ Only available at readyState 3 and 4 universally and in readyState 2
+ in Gecko.
+ */
+ proto.getResponseHeader = function(headerName)
+ {
+ if (!this._req && !this._responseHeaders)
+ {
+ return null;
+ }
+ else if (!this._req && this._responseHeaders)
+ {
+ if (this._responseHeaders[headerName])
+ {
+ return this._responseHeaders[headerName];
+ }
+ else
+ {
+ return null;
+ };
+ }
+ else if (this._req)
+ {
+ switch (this._req.readyState)
+ {
+ case 0:
+ case 1:
+ case 2:
+ return null;
+
+ case 3:
+ case 4:
+ return this._req.getResponseHeader(headerName);
+
+ default:
+ throw new Error("Unknown ready state reached!");
+ };
+ };
+ };
+
+ /*!
+ Provides an array of all response headers.
+ */
+ proto.getResponseHeaders = function()
+ {
+ if (!this._req && !this._responseHeaders)
+ {
+ return null;
+ }
+ else if (!this._req && this._responseHeaders)
+ {
+ return this._responseHeaders;
+ }
+ else if (this._req)
+ {
+ switch (this._req.readyState)
+ {
+ case 0:
+ case 1:
+ case 2:
+ return null;
+
+ case 3:
+ case 4:
+ return this._req.getAllResponseHeaders();
+
+ default:
+ throw new Error("Unknown ready state reached!");
+ };
+ };
+ };
+
+
+
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ STATUS SUPPORT
+ ---------------------------------------------------------------------------
+ */
+
+ /*!
+ Returns the current status code of the request if available or -1 if not.
+ */
+ proto.getStatusCode = function()
+ {
+ if (!this._req)
+ {
+ return this._status;
+ }
+ else
+ {
+ switch (this._req.readyState)
+ {
+ case 0:
+ case 1:
+ return -1;
+ break;
+
+ case 2:
+ if (QxHttpTransport._requestCtor == QxHttpTransport._activeXRequest) {
+ return -1;
+ }
+ // no break here?
+
+ case 3:
+ case 4:
+ return this._req.status;
+ break;
+ };
+ };
+ };
+
+ /*!
+ Provides the status text for the current request if available and null otherwise.
+ */
+ proto.getStatusText = function()
+ {
+ if (this.getStatusCode() != -1)
+ {
+ return this._req ? this._req.statusText : this._statusText;
+ }
+ else
+ {
+ return null;
+ };
+ };
+
+ /*!
+ Provides the current readyState of the request if available, and -1 otherwise.
+ */
+ proto.getReadyState = function() {
+ return this._req == null ? -1 : this._req.readyState;
+ };
+
+ /*!
+ Provides the response text from the request when available and null otherwise.
+ By passing true as the "partial" parameter of this method, incomplete data will
+ be made available to the caller.
+ */
+ proto.getResponseText = function(partial)
+ {
+ var minState = 4;
+
+ if (!this._req && this._responseText) {
+ return this._responseText;
+ };
+
+ if (partial || partial == true) {
+ minState = 3;
+ };
+
+ return minState <= this.getReadyState() ? this._req.responseText : null;
+ };
+
+ /*!
+ Provides the XML provided by the response if any and null otherwise.
+ By passing true as the "partial" parameter of this method, incomplete data will
+ be made available to the caller.
+ */
+ proto.getResponseXML = function(partial)
+ {
+ var minState = 4;
+
+ if (!this._req && this._responseXML) {
+ return this._responseXML;
+ };
+
+ if (partial || partial == true) {
+ minState = 3;
+ };
+
+ return minState <= this.getReadyState() ? this._req.responseXML : null;
+ };
+
+ /*!
+ Returns the length of the content as fetched thus far
+ */
+ proto.getFetchedLength = function()
+ {
+ // Internet Explorer throws an exception here unless readyState = 4 for some odd reason
+ // DISCUSS: Is this really true (wpbasti)?
+ if (!this._req || QxClient.isMshtml())
+ {
+ return -1;
+ }
+ else
+ {
+ return this._req.responseText.length;
+ };
+ };
+
+
+
+
+
+
+
+ /*
+ ---------------------------------------------------------------------------
+ DISPOSER
+ ---------------------------------------------------------------------------
+ */
+
+ proto.dispose = function()
+ {
+ if (this.getDisposed()) {
+ return;
+ };
+
+ this._req = null;
+
+ return QxTarget.prototype.dispose.call(this);
+ };
|