diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-11-16 15:34:23 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-19 09:57:16 +0000 |
commit | 977c8b01c042f2ffec36e3cb5c7ad517b738d06e (patch) | |
tree | 33f83d3070a0a5fbae9f3f3800d6b9f2b2535ddf /server | |
parent | 9a3a22cc9f8f95054e3528b0ffcc0b9e92cffbea (diff) | |
download | vaadin-framework-977c8b01c042f2ffec36e3cb5c7ad517b738d06e.tar.gz vaadin-framework-977c8b01c042f2ffec36e3cb5c7ad517b738d06e.zip |
Read browser width and height from request in Page.init (#9073)
* Also change default screen width and height in WebBrowser to -1 for consistency
* Test for reading browser details in UI.init
Change-Id: I24339fd3742857392e1fc768696eeb2fb5551a90
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/Page.java | 18 | ||||
-rw-r--r-- | server/src/com/vaadin/server/WebBrowser.java | 6 |
2 files changed, 18 insertions, 6 deletions
diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index cf77c09324..501172f80a 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -436,15 +436,27 @@ public class Page implements Serializable { public void init(VaadinRequest request) { // Extract special parameter sent by vaadinBootstrap.js - String loc = request.getParameter("loc"); - if (loc != null) { + String location = request.getParameter("loc"); + String clientWidth = request.getParameter("cw"); + String clientHeight = request.getParameter("ch"); + + if (location != null) { try { - location = new URI(loc); + this.location = new URI(location); } catch (URISyntaxException e) { throw new RuntimeException( "Invalid location URI received from client", e); } } + if (clientWidth != null && clientHeight != null) { + try { + browserWindowWidth = Integer.parseInt(clientWidth); + browserWindowHeight = Integer.parseInt(clientHeight); + } catch (NumberFormatException e) { + throw new RuntimeException( + "Invalid window size received from client", e); + } + } } public WebBrowser getWebBrowser() { diff --git a/server/src/com/vaadin/server/WebBrowser.java b/server/src/com/vaadin/server/WebBrowser.java index 676375a693..4df535a39a 100644 --- a/server/src/com/vaadin/server/WebBrowser.java +++ b/server/src/com/vaadin/server/WebBrowser.java @@ -32,8 +32,8 @@ import com.vaadin.shared.VBrowserDetails; */ public class WebBrowser implements Serializable { - private int screenHeight = 0; - private int screenWidth = 0; + private int screenHeight = -1; + private int screenWidth = -1; private String browserApplication = null; private Locale locale; private String address; @@ -364,7 +364,7 @@ public class WebBrowser implements Serializable { screenHeight = Integer.parseInt(sh); screenWidth = Integer.parseInt(sw); } catch (final NumberFormatException e) { - screenHeight = screenWidth = 0; + screenHeight = screenWidth = -1; } } if (tzo != null) { |