From a7a8f4f9c9bbbd3bd16605235440dec29f581ad7 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 28 May 2012 16:49:36 +0000 Subject: Improvements to the hosted composite management app. Simplify and optimize the Web UI a bit. Add test cases and fix some of the logic in the management components. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1343316 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/js/htdocs/component.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'sca-cpp/trunk/modules/js/htdocs/component.js') diff --git a/sca-cpp/trunk/modules/js/htdocs/component.js b/sca-cpp/trunk/modules/js/htdocs/component.js index 10b4535470..c3799ef708 100644 --- a/sca-cpp/trunk/modules/js/htdocs/component.js +++ b/sca-cpp/trunk/modules/js/htdocs/component.js @@ -191,6 +191,7 @@ HTTPBindingClient.prototype.jsonApply = function(req) { var http = HTTPBindingClient.getHTTPRequest(); var hascb = req.cb? true : false; http.open("POST", this.uri, hascb); + http.setRequestHeader("Accept", "*/*"); http.setRequestHeader("Content-Type", "application/json-rpc"); // Construct call back if we have one @@ -238,7 +239,9 @@ HTTPBindingClient.prototype.get = function(id, cb) { var hascb = cb? true : false; // Get from local storage first - var item = localStorage.getItem(u); + var ls = window.lstorage || localStorage; + var item = null; + try { item = ls.getItem(u); } catch(e) {} //log('localStorage.getItem', u, item); if (item != null && item != '') { if (!hascb) @@ -253,6 +256,7 @@ HTTPBindingClient.prototype.get = function(id, cb) { // Connect to the service var http = HTTPBindingClient.getHTTPRequest(); http.open("GET", u, hascb); + http.setRequestHeader("Accept", "*/*"); // Construct call back if we have one if (hascb) { @@ -282,7 +286,7 @@ HTTPBindingClient.prototype.get = function(id, cb) { // Store retrieved entry in local storage if (http.responseText != null) { //log('localStorage.setItem', u, http.responseText); - localStorage.setItem(u, http.responseText); + try { ls.setItem(u, http.responseText); } catch(e) {} } try { return cb(http.responseText); @@ -337,6 +341,7 @@ HTTPBindingClient.prototype.getnocache = function(id, cb) { // Connect to the service var http = HTTPBindingClient.getHTTPRequest(); http.open("GET", u, hascb); + http.setRequestHeader("Accept", "*/*"); // Construct call back if we have one if (hascb) { @@ -407,6 +412,7 @@ HTTPBindingClient.prototype.post = function (entry, cb) { var http = HTTPBindingClient.getHTTPRequest(); var hascb = cb? true : false; http.open("POST", this.uri, hascb); + http.setRequestHeader("Accept", "*/*"); http.setRequestHeader("Content-Type", "application/atom+xml"); // Construct call back if we have one @@ -445,13 +451,15 @@ HTTPBindingClient.prototype.put = function (id, entry, cb) { var u = this.uri + '/' + id; // Update local storage - localStorage.setItem(u, entry); + var ls = window.lstorage || localStorage; + try { ls.setItem(u, entry); } catch(e) {} //log('localStorage.setItem', u, entry); // Connect to the service var http = HTTPBindingClient.getHTTPRequest(); var hascb = cb? true : false; http.open("PUT", u, hascb); + http.setRequestHeader("Accept", "*/*"); http.setRequestHeader("Content-Type", "application/atom+xml"); // Construct call back if we have one @@ -489,13 +497,15 @@ HTTPBindingClient.prototype.del = function (id, cb) { var u = this.uri + '/' + id; // Update local storage - localStorage.removeItem(u); + var ls = window.lstorage || localStorage; + try { ls.removeItem(u); } catch(e) {} //log('localStorage.removeItem', u); // Connect to the service var http = HTTPBindingClient.getHTTPRequest(); var hascb = cb? true : false; http.open("DELETE", u, hascb); + http.setRequestHeader("Accept", "*/*"); // Construct call back if we have one if (cb) { -- cgit v1.2.3