Browse Source

Export fetchRootConfig status so it can be read by TK (#14053)

Offline apps need to know when server errors are 500 or 400 in
order to switch appropriatelly to the offline mode.
Also we need exported the fetchRootConfig method and a
reliable way to get loaded apps.

Related with change I29635982514071e63221a9771d6729da14273ad3 [1]
see temporal workaround in TouchKitServlet
[1] https://dev.vaadin.com/review/#/c/4037/

Change-Id: I339ca697d035508a67d1eb24480cd12c4b9c6c0e
tags/7.3.0.rc1
Manolo Carrasco 10 years ago
parent
commit
7326935a82
1 changed files with 24 additions and 4 deletions
  1. 24
    4
      WebContent/VAADIN/vaadinBootstrap.js

+ 24
- 4
WebContent/VAADIN/vaadinBootstrap.js View File

@@ -101,7 +101,7 @@
return value;
};
var fetchRootConfig = function() {
var fetchRootConfig = function(callback) {
log('Fetching root config');
var url = getConfig('browserDetailsUrl');
if (!url) {
@@ -141,6 +141,12 @@
r.open('POST', url, true);
r.onreadystatechange = function (aEvt) {
if (r.readyState == 4) {
// Save responseStatus so as Offline Applications know what happened
// when loading root configuration from server, and depending on the
// error status display an error message or the offline UI.
config.rootResponseStatus = r.status;
config.rootResponseText = r.responseText;

var text = r.responseText;
if (r.status == 200){
log("Got root config response", text);
@@ -166,6 +172,9 @@
appDiv.innerHTML = text;
appDiv.style['overflow'] = 'auto';
}

// Run the fetchRootConfig callback if present.
callback && callback(r);
}
};
// send parameters as POST data
@@ -177,7 +186,10 @@
//Export public data
var app = {
'getConfig': getConfig
getConfig: getConfig,
// Used when the app was started in offline, so as it is possible
// to defer root configuration loading until network is available.
fetchRootConfig: fetchRootConfig
};
apps[appId] = app;
@@ -224,9 +236,17 @@
return app;
},
clients: {},
getAppIds: function() {
var ids = [ ];
for (var id in apps) {
if (apps.hasOwnProperty(id)) {
ids.push(id);
}
}
return ids;
},
getApp: function(appId) {
var app = apps[appId];
return app;
return apps[appId];
},
loadTheme: loadTheme,
registerWidgetset: function(widgetset, callback) {

Loading…
Cancel
Save