I found some issues using our Store scenario in Internet Explorer and
after some investigation, realized that the issue was related to a IE
behavior that was not populating responseXML for non xml contentTypes.
I have updated the Feed javascript client to overcome this IE
limitation and it is now parsing responseText  when responseXML is not
available. With these changes, our store sample works fine in both IE
and FireFox.

Please let me know if you find any issues with our Feed binding
JavaScript client.


---------- Forwarded message ----------
From:  <[EMAIL PROTECTED]>
Date: Dec 27, 2007 10:49 AM
Subject: svn commit: r607107 - in /incubator/tuscany/java/sca:
demos/customer-map/src/main/resources/html/
modules/binding-feed/src/main/resources/org.apache.tuscany.binding.feed/
modules/implementation-widget/src/main/resources/
To: [EMAIL PROTECTED]


Author: lresende
Date: Thu Dec 27 10:49:10 2007
New Revision: 607107

URL: http://svn.apache.org/viewvc?rev=607107&view=rev
Log:
Adding support for AtomClient JS in Internet Explorer

Modified:
    
incubator/tuscany/java/sca/demos/customer-map/src/main/resources/html/binding-atom.js
    
incubator/tuscany/java/sca/modules/binding-feed/src/main/resources/org.apache.tuscany.binding.feed/binding-atom.js
    
incubator/tuscany/java/sca/modules/implementation-widget/src/main/resources/binding-atom.js

Modified: 
incubator/tuscany/java/sca/demos/customer-map/src/main/resources/html/binding-atom.js
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/customer-map/src/main/resources/html/binding-atom.js?rev=607107&r1=607106&r2=607107&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/demos/customer-map/src/main/resources/html/binding-atom.js
(original)
+++ 
incubator/tuscany/java/sca/demos/customer-map/src/main/resources/html/binding-atom.js
Thu Dec 27 10:49:10 2007
@@ -18,7 +18,13 @@
  */

 function AtomClient(uri) {
-
+
+       this.msxmlNames = [ "MSXML2.XMLHTTP.5.0",
+                        "MSXML2.XMLHTTP.4.0",
+                        "MSXML2.XMLHTTP.3.0",
+                        "MSXML2.XMLHTTP",
+                        "Microsoft.XMLHTTP" ];
+
        this.uri=uri;

        this.get = function(id, responseFunction) {
@@ -26,9 +32,14 @@
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 200) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                    if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
-                                       alert("get - Error getting
data from the server");
+                    alert("get - Error getting data from the server");
                                }
                        }
                }
@@ -40,7 +51,12 @@
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 201) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                                       if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
                                        alert("post - Error getting
data from the server");
                                }
@@ -49,13 +65,18 @@
                xhr.open("POST", uri, true);
                xhr.setRequestHeader("Content-Type", "application/atom+xml");
                xhr.send(entry);
-       }
+       }
        this.put = function (id, entry, responseFunction) {
                var xhr = this.createXMLHttpRequest();
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 200) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                                       if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
                                        alert("put - Error getting
data from the server");
                                }
@@ -65,7 +86,7 @@
                xhr.setRequestHeader("Content-Type", "application/atom+xml");
                xhr.send(entry);
        }
-       this.delete = function (id, responseFunction) {
+       this.del = function (id, responseFunction) {
                var xhr = this.createXMLHttpRequest();
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
@@ -79,14 +100,36 @@
                xhr.open("DELETE", uri + id, true);
                xhr.send(null);
        }
-
        this.createXMLHttpRequest = function () {
-               try {return new XMLHttpRequest();} catch(e) {}
-               try {return new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {}
-               try {return new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {}
-               alert("XML http request not supported");
-               return null;
+        /* Mozilla XMLHttpRequest */
+        try {return new XMLHttpRequest();} catch(e) {}
+
+        /* Microsoft MSXML ActiveX */
+        for (var i=0;i < this.msxmlNames.length; i++) {
+            try {return new ActiveXObject(this.msxmlNames[i]);} catch (e) {}
+        }
+        alert("XML http request not supported");
+        return null;
        }
+       if (typeof DOMParser == "undefined") {
+          DOMParser = function () {}
+
+          DOMParser.prototype.parseFromString = function (str, contentType) {
+             if (typeof ActiveXObject != "undefined") {
+                var d = new ActiveXObject("MSXML.DomDocument");
+                d.loadXML(str);
+                return d;
+             } else if (typeof XMLHttpRequest != "undefined") {
+                var req = new XMLHttpRequest;
+                req.open("GET", "data:" + (contentType || "application/xml") +
+                                ";charset=utf-8," +
encodeURIComponent(str), false);
+                if (req.overrideMimeType) {
+                   req.overrideMimeType(contentType);
+                }
+                req.send(null);
+                return req.responseXML;
+             }
+      }
+   }
 }
-
 bindingatom = "loaded";

Modified: 
incubator/tuscany/java/sca/modules/binding-feed/src/main/resources/org.apache.tuscany.binding.feed/binding-atom.js
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-feed/src/main/resources/org.apache.tuscany.binding.feed/binding-atom.js?rev=607107&r1=607106&r2=607107&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-feed/src/main/resources/org.apache.tuscany.binding.feed/binding-atom.js
(original)
+++ 
incubator/tuscany/java/sca/modules/binding-feed/src/main/resources/org.apache.tuscany.binding.feed/binding-atom.js
Thu Dec 27 10:49:10 2007
@@ -18,7 +18,13 @@
  */

 function AtomClient(uri) {
-
+
+       this.msxmlNames = [ "MSXML2.XMLHTTP.5.0",
+                        "MSXML2.XMLHTTP.4.0",
+                        "MSXML2.XMLHTTP.3.0",
+                        "MSXML2.XMLHTTP",
+                        "Microsoft.XMLHTTP" ];
+
        this.uri=uri;

        this.get = function(id, responseFunction) {
@@ -26,9 +32,14 @@
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 200) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                    if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
-                                       alert("get - Error getting
data from the server");
+                    alert("get - Error getting data from the server");
                                }
                        }
                }
@@ -40,7 +51,12 @@
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 201) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                                       if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
                                        alert("post - Error getting
data from the server");
                                }
@@ -49,13 +65,18 @@
                xhr.open("POST", uri, true);
                xhr.setRequestHeader("Content-Type", "application/atom+xml");
                xhr.send(entry);
-       }
+       }
        this.put = function (id, entry, responseFunction) {
                var xhr = this.createXMLHttpRequest();
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 200) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                                       if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
                                        alert("put - Error getting
data from the server");
                                }
@@ -79,14 +100,36 @@
                xhr.open("DELETE", uri + id, true);
                xhr.send(null);
        }
-
        this.createXMLHttpRequest = function () {
-               try {return new XMLHttpRequest();} catch(e) {}
-               try {return new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {}
-               try {return new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {}
-               alert("XML http request not supported");
-               return null;
+        /* Mozilla XMLHttpRequest */
+        try {return new XMLHttpRequest();} catch(e) {}
+
+        /* Microsoft MSXML ActiveX */
+        for (var i=0;i < this.msxmlNames.length; i++) {
+            try {return new ActiveXObject(this.msxmlNames[i]);} catch (e) {}
+        }
+        alert("XML http request not supported");
+        return null;
        }
+       if (typeof DOMParser == "undefined") {
+          DOMParser = function () {}
+
+          DOMParser.prototype.parseFromString = function (str, contentType) {
+             if (typeof ActiveXObject != "undefined") {
+                var d = new ActiveXObject("MSXML.DomDocument");
+                d.loadXML(str);
+                return d;
+             } else if (typeof XMLHttpRequest != "undefined") {
+                var req = new XMLHttpRequest;
+                req.open("GET", "data:" + (contentType || "application/xml") +
+                                ";charset=utf-8," +
encodeURIComponent(str), false);
+                if (req.overrideMimeType) {
+                   req.overrideMimeType(contentType);
+                }
+                req.send(null);
+                return req.responseXML;
+             }
+      }
+   }
 }
-
 bindingatom = "loaded";

Modified: 
incubator/tuscany/java/sca/modules/implementation-widget/src/main/resources/binding-atom.js
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/main/resources/binding-atom.js?rev=607107&r1=607106&r2=607107&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-widget/src/main/resources/binding-atom.js
(original)
+++ 
incubator/tuscany/java/sca/modules/implementation-widget/src/main/resources/binding-atom.js
Thu Dec 27 10:49:10 2007
@@ -18,7 +18,13 @@
  */

 function AtomClient(uri) {
-
+
+       this.msxmlNames = [ "MSXML2.XMLHTTP.5.0",
+                        "MSXML2.XMLHTTP.4.0",
+                        "MSXML2.XMLHTTP.3.0",
+                        "MSXML2.XMLHTTP",
+                        "Microsoft.XMLHTTP" ];
+
        this.uri=uri;

        this.get = function(id, responseFunction) {
@@ -26,9 +32,14 @@
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 200) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                    if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
-                                       alert("get - Error getting
data from the server");
+                    alert("get - Error getting data from the server");
                                }
                        }
                }
@@ -40,7 +51,12 @@
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 201) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                                       if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
                                        alert("post - Error getting
data from the server");
                                }
@@ -49,13 +65,18 @@
                xhr.open("POST", uri, true);
                xhr.setRequestHeader("Content-Type", "application/atom+xml");
                xhr.send(entry);
-       }
+       }
        this.put = function (id, entry, responseFunction) {
                var xhr = this.createXMLHttpRequest();
                xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                                if (xhr.status == 200) {
-                                       if (responseFunction != null)
responseFunction(xhr.responseXML);
+                                   var strDocument = xhr.responseText;
+                                   var xmlDocument = xhr.responseXML;
+                                   if(!xmlDocument ||
xmlDocument.childNodes.length==0){
+                        xmlDocument = (new
DOMParser()).parseFromString(strDocument, "text/xml");
+                    }
+                                       if (responseFunction != null)
responseFunction(xmlDocument);
                                } else {
                                        alert("put - Error getting
data from the server");
                                }
@@ -79,12 +100,36 @@
                xhr.open("DELETE", uri + id, true);
                xhr.send(null);
        }
-
        this.createXMLHttpRequest = function () {
-               try {return new XMLHttpRequest();} catch(e) {}
-               try {return new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {}
-               try {return new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {}
-               alert("XML http request not supported");
-               return null;
+        /* Mozilla XMLHttpRequest */
+        try {return new XMLHttpRequest();} catch(e) {}
+
+        /* Microsoft MSXML ActiveX */
+        for (var i=0;i < this.msxmlNames.length; i++) {
+            try {return new ActiveXObject(this.msxmlNames[i]);} catch (e) {}
+        }
+        alert("XML http request not supported");
+        return null;
        }
+       if (typeof DOMParser == "undefined") {
+          DOMParser = function () {}
+
+          DOMParser.prototype.parseFromString = function (str, contentType) {
+             if (typeof ActiveXObject != "undefined") {
+                var d = new ActiveXObject("MSXML.DomDocument");
+                d.loadXML(str);
+                return d;
+             } else if (typeof XMLHttpRequest != "undefined") {
+                var req = new XMLHttpRequest;
+                req.open("GET", "data:" + (contentType || "application/xml") +
+                                ";charset=utf-8," +
encodeURIComponent(str), false);
+                if (req.overrideMimeType) {
+                   req.overrideMimeType(contentType);
+                }
+                req.send(null);
+                return req.responseXML;
+             }
+      }
+   }
 }
+bindingatom = "loaded";
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
Luciano Resende
Apache Tuscany Committer
http://people.apache.org/~lresende
http://lresende.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to