summaryrefslogtreecommitdiffstats
path: root/documentation/articles/AccessingWebPageAndBrowserInformation.asciidoc
diff options
context:
space:
mode:
authorErik Lumme <erik@vaadin.com>2017-09-11 14:02:42 +0300
committerErik Lumme <erik@vaadin.com>2017-09-11 14:02:42 +0300
commit6a03ddc414dd850e30eecfcee608143a6e01cc99 (patch)
tree599dbba16d5e2a974a41599ab229c2fae10ae630 /documentation/articles/AccessingWebPageAndBrowserInformation.asciidoc
parentb75136b70f6a2fa0613ebf250c3dfe426543e0f2 (diff)
downloadvaadin-framework-6a03ddc414dd850e30eecfcee608143a6e01cc99.tar.gz
vaadin-framework-6a03ddc414dd850e30eecfcee608143a6e01cc99.zip
Migrate documentation files and change typo
Diffstat (limited to 'documentation/articles/AccessingWebPageAndBrowserInformation.asciidoc')
-rw-r--r--documentation/articles/AccessingWebPageAndBrowserInformation.asciidoc50
1 files changed, 50 insertions, 0 deletions
diff --git a/documentation/articles/AccessingWebPageAndBrowserInformation.asciidoc b/documentation/articles/AccessingWebPageAndBrowserInformation.asciidoc
new file mode 100644
index 0000000000..2aea7b8d1a
--- /dev/null
+++ b/documentation/articles/AccessingWebPageAndBrowserInformation.asciidoc
@@ -0,0 +1,50 @@
+[[accessing-web-page-and-browser-information]]
+Accessing web page and browser information
+------------------------------------------
+
+Vaadin 7 includes a new *Page* class offering access to various
+client-side information and events concerning the web page and browser
+window in which the Vaadin UI resides. The Page instance corresponding
+to a given UI is accessed via the `getPage()` method of the UI or using
+a static method `Page.getCurrent()`.
+
+You can access the browser window size and add size change listeners:
+
+[source,java]
+....
+Page page = someUI.getPage();
+page.addBrowserWindowResizeListener(new BrowserWindowResizeListener() {
+ public void browserWindowResized(BrowserWindowResizeEvent event) {
+ Notification.show("Window width=" + event.getWidth() + ", height=" + event.getHeight());
+ }
+});
+....
+
+You can access the optional fragment part of the location URI and add
+fragment change listeners:
+
+[source,java]
+....
+page.setUriFragment(page.getUriFragment() + "foo");
+page.addUriFragmentChangedListener(new UriFragmentChangedListener() {
+ public void uriFragmentChanged(UriFragmentChangedEvent event) {
+ Notification.show("Fragment=" + event.getUriFragment());
+ }
+});
+....
+
+You can access client browser details:
+
+[source,java]
+....
+Notification.show("IP" + browser.getAddress() +
+ "User-Agent:" + browser.getBrowserApplication() +
+ "Linux: " + browser.isLinux());
+....
+
+https://demo.vaadin.com/sampler/#foundation/advanced/browser-information[Live
+Demo]
+
+Note: If you are using a reverse proxy, you must get the value
+`X-Forwarded-For` from request headers. You cannot get a browser name,
+but you can check which browser are using.