From 16bcacd5eb5d56491b4fb4777bab950880b644f3 Mon Sep 17 00:00:00 2001 From: Tapio Aali Date: Tue, 29 Apr 2014 15:56:43 +0300 Subject: Modified vaadinBootstrap to send v-loc as POST instead of GET (#13685). Since there seems to be no difference, moved also almost all other parameters from GET to POST for consistency. Change-Id: I528963c4c832339a9853fbee97cebcb8fabb35e1 --- WebContent/VAADIN/vaadinBootstrap.js | 50 +++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'WebContent/VAADIN/vaadinBootstrap.js') diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index bab759b812..fc0fb9b948 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -108,29 +108,29 @@ // No special url defined, use the same URL that loaded this page (without the fragment) url = window.location.href.replace(/#.*/,''); } - url += ((/\?/).test(url) ? "&" : "?") + "v-browserDetails=1"; + // Timestamp to avoid caching + url += ((/\?/).test(url) ? "&" : "?") + "v-" + (new Date()).getTime(); + + var params = "v-browserDetails=1"; var rootId = getConfig("v-rootId"); if (rootId !== undefined) { - url += "&v-rootId=" + rootId; + params += "&v-rootId=" + rootId; } // Tell the UI what theme it is configured to use var theme = getConfig('theme'); if (theme !== undefined) { - url += '&theme=' + encodeURIComponent(theme); + params += '&theme=' + encodeURIComponent(theme); } - url += "&v-appId=" + appId; + params += "&v-appId=" + appId; var extraParams = getConfig('extraParams') if (extraParams !== undefined) { - url += extraParams; + params += extraParams; } - url += '&' + vaadin.getBrowserDetailsParameters(appId); - - // Timestamp to avoid caching - url += '&v-' + (new Date()).getTime(); + params += '&' + vaadin.getBrowserDetailsParameters(appId); var r; try { @@ -168,7 +168,9 @@ } } }; - r.send(null); + // send parameters as POST data + r.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + r.send(params); log('sending request to ', url); }; @@ -239,8 +241,8 @@ }, getBrowserDetailsParameters: function(parentElementId) { // Screen height and width - var url = 'v-sh=' + window.screen.height; - url += '&v-sw=' + window.screen.width; + var params = 'v-sh=' + window.screen.height; + params += '&v-sw=' + window.screen.width; // Window height and width var cw = 0; @@ -254,12 +256,12 @@ cw = document.documentElement.clientWidth; ch = document.documentElement.clientHeight; } - url += '&v-cw=' + cw + '&v-ch=' + ch; + params += '&v-cw=' + cw + '&v-ch=' + ch; var d = new Date(); - url += '&v-curdate=' + d.getTime(); + params += '&v-curdate=' + d.getTime(); var tzo1 = d.getTimezoneOffset(); // current offset var dstDiff = 0; @@ -276,29 +278,29 @@ } // Time zone offset - url += '&v-tzo=' + tzo1; + params += '&v-tzo=' + tzo1; // DST difference - url += '&v-dstd=' + dstDiff; + params += '&v-dstd=' + dstDiff; // Raw time zone offset - url += '&v-rtzo=' + rtzo; + params += '&v-rtzo=' + rtzo; // DST in effect? - url += '&v-dston=' + (tzo1 != rtzo); + params += '&v-dston=' + (tzo1 != rtzo); var pe = document.getElementById(parentElementId); if (pe) { - url += '&v-vw=' + pe.offsetWidth; - url += '&v-vh=' + pe.offsetHeight; + params += '&v-vw=' + pe.offsetWidth; + params += '&v-vh=' + pe.offsetHeight; } // Location - url += '&v-loc=' + encodeURIComponent(location.href); + params += '&v-loc=' + encodeURIComponent(location.href); // Window name if (window.name) { - url += '&v-wn=' + encodeURIComponent(window.name); + params += '&v-wn=' + encodeURIComponent(window.name); } // Detect touch device support @@ -313,10 +315,10 @@ } if (supportsTouch) { - url += "&v-td=1"; + params += "&v-td=1"; } - return url; + return params; } }; -- cgit v1.2.3 From 3ecad007706be76bcd2183dd128259b94fdeb67a Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 9 May 2014 09:47:14 +0200 Subject: Avoid Vaadin entry-point being run twice (#13730) - Prevent bootstrap script fail if registerWidgetset is called twice with the same widgetset. Change-Id: I8b8069b442ea91c1aa0f0b7dd73c41902e75094b --- WebContent/VAADIN/vaadinBootstrap.js | 15 +++++++++------ .../src/com/vaadin/client/ApplicationConfiguration.java | 8 ++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'WebContent/VAADIN/vaadinBootstrap.js') diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index fc0fb9b948..ea1ea21b46 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -231,13 +231,16 @@ loadTheme: loadTheme, registerWidgetset: function(widgetset, callback) { log("Widgetset registered", widgetset); - widgetsets[widgetset].callback = callback; - for(var i = 0; i < widgetsets[widgetset].pendingApps.length; i++) { - var appId = widgetsets[widgetset].pendingApps[i]; - log("Starting from register widgetset", appId); - callback(appId); + var ws = widgetsets[widgetset]; + if (ws && ws.pendingApps) { + ws.callback = callback; + for(var i = 0; i < ws.pendingApps.length; i++) { + var appId = ws.pendingApps[i]; + log("Starting from register widgetset", appId); + callback(appId); + } + ws.pendingApps = null; } - widgetsets[widgetset].pendingApps = null; }, getBrowserDetailsParameters: function(parentElementId) { // Screen height and width diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java index d483b39a7b..543a48f61b 100644 --- a/client/src/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/client/ApplicationConfiguration.java @@ -222,6 +222,7 @@ public class ApplicationConfiguration implements EntryPoint { private boolean browserDetailsSent = false; private boolean widgetsetVersionSent = false; + private static boolean moduleLoaded = false; static// TODO consider to make this hashmap per application LinkedList callbacks = new LinkedList(); @@ -596,6 +597,13 @@ public class ApplicationConfiguration implements EntryPoint { @Override public void onModuleLoad() { + + // Don't run twice if the module has been inherited several times. + if (moduleLoaded) { + return; + } + moduleLoaded = true; + Profiler.initialize(); Profiler.enter("ApplicationConfiguration.onModuleLoad"); -- cgit v1.2.3