summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebContent/VAADIN/vaadinBootstrap.js34
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java1
2 files changed, 31 insertions, 4 deletions
diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js
index 9e012ae987..81adfcccc6 100644
--- a/WebContent/VAADIN/vaadinBootstrap.js
+++ b/WebContent/VAADIN/vaadinBootstrap.js
@@ -55,19 +55,45 @@
pendingApps: []
};
};
-
+
+ var isInitializedInDom = function(appId) {
+ var appDiv = document.getElementById(appId);
+ if (!appDiv) {
+ return false;
+ }
+ for ( var i = 0; i < appDiv.childElementCount; i++) {
+ var className = appDiv.childNodes[i].className;
+ // If the app div contains a child with the class
+ // "v-app-loading" we have only received the HTML
+ // but not yet started the widget set
+ // (UIConnector removes the v-app-loading div).
+ if (className && className.contains("v-app-loading")) {
+ return false;
+ }
+ }
+ return true;
+ };
+
window.vaadin = window.vaadin || {
initApplication: function(appId, config) {
+ var testbenchId = appId.replace(/-\d+$/, '');
+
if (apps[appId]) {
- throw "Application " + appId + " already initialized";
+ if (window.vaadin && window.vaadin.clients && window.vaadin.clients[testbenchId] && window.vaadin.clients[testbenchId].initializing) {
+ throw "Application " + appId + " is already being initialized";
+ }
+ if (isInitializedInDom(appId)) {
+ throw "Application " + appId + " already initialized";
+ }
}
+
log("init application", appId, config);
- var testbenchId = appId.replace(/-\d+$/, '');
window.vaadin.clients[testbenchId] = {
isActive: function() {
return true;
- }
+ },
+ initializing: true
};
var getConfig = function(name) {
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 62827feffb..4ddbd7c39b 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -510,6 +510,7 @@ public class ApplicationConnection {
client.getPathForElement = $entry(function(element) {
return componentLocator.@com.vaadin.client.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element);
});
+ client.initializing = false;
$wnd.vaadin.clients[TTAppId] = client;
}-*/;