From b057fe32dd0973c2f9f9df5100706c5952a36abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olli=20Tiet=C3=A4v=C3=A4inen?= Date: Fri, 25 Apr 2025 12:17:58 +0300 Subject: [PATCH 1/4] Update browser-access.adoc Added information about how to get the `WebBrowser` object --- articles/flow/advanced/browser-access.adoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/articles/flow/advanced/browser-access.adoc b/articles/flow/advanced/browser-access.adoc index 677840ddee..d9235a2e15 100644 --- a/articles/flow/advanced/browser-access.adoc +++ b/articles/flow/advanced/browser-access.adoc @@ -32,6 +32,23 @@ UI.getCurrent().getPage().fetchCurrentURL(currentUrl -> { ---- // TODO add documentation on VaadinSession.getCurrent().getBrowser() +== Accessing browser information + +The initial request contains the user-agent information supplied by the browser. These details can be found from the WebBrowser object, +which is accessible from the current VaadinSession object: + +.Getting the browser object +[source,java] +---- +WebBrowser browser = VaadinSession.getCurrent().getBrowser(); +// Print the raw user-agent string +System.out.println(browser.getBrowserApplication()); +// Print some parsed browser details +System.out.println("Is Windows: " + browser.isWindows()); +System.out.println("Is Chrome: " + browser.isChrome()); +System.out.println("Major version: " + browser.getBrowserMajorVersion()); +---- + == Getting the Extended Client-Side Details From 2796b560453af53f5908b9bf79f278d3d2d37aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olli=20Tiet=C3=A4v=C3=A4inen?= Date: Wed, 30 Apr 2025 14:03:23 +0300 Subject: [PATCH 2/4] Review comment updates --- articles/flow/advanced/browser-access.adoc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/articles/flow/advanced/browser-access.adoc b/articles/flow/advanced/browser-access.adoc index d9235a2e15..e1fe5aad7f 100644 --- a/articles/flow/advanced/browser-access.adoc +++ b/articles/flow/advanced/browser-access.adoc @@ -32,10 +32,9 @@ UI.getCurrent().getPage().fetchCurrentURL(currentUrl -> { ---- // TODO add documentation on VaadinSession.getCurrent().getBrowser() -== Accessing browser information +== Accessing Browser Information -The initial request contains the user-agent information supplied by the browser. These details can be found from the WebBrowser object, -which is accessible from the current VaadinSession object: +During the initial HTTP request, Vaadin reads the user-agent information supplied by the browser and stores them in a [classname]`WebBrowser` instance, which is accessible from the current [classname]`VaadinSession`. .Getting the browser object [source,java] From 8e1416577e5f050bc6641fdf7c3f2df13e5f90ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olli=20Tiet=C3=A4v=C3=A4inen?= Date: Wed, 30 Apr 2025 15:09:39 +0300 Subject: [PATCH 3/4] Remove unnecessary comment --- articles/flow/advanced/browser-access.adoc | 1 - 1 file changed, 1 deletion(-) diff --git a/articles/flow/advanced/browser-access.adoc b/articles/flow/advanced/browser-access.adoc index e1fe5aad7f..75eedfa6ce 100644 --- a/articles/flow/advanced/browser-access.adoc +++ b/articles/flow/advanced/browser-access.adoc @@ -31,7 +31,6 @@ UI.getCurrent().getPage().fetchCurrentURL(currentUrl -> { }); ---- -// TODO add documentation on VaadinSession.getCurrent().getBrowser() == Accessing Browser Information During the initial HTTP request, Vaadin reads the user-agent information supplied by the browser and stores them in a [classname]`WebBrowser` instance, which is accessible from the current [classname]`VaadinSession`. From b0b5d080957c4b8b5696c6dbe483b4d6e013dccd Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Thu, 8 May 2025 09:47:14 +0300 Subject: [PATCH 4/4] minor edit --- articles/flow/advanced/browser-access.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/articles/flow/advanced/browser-access.adoc b/articles/flow/advanced/browser-access.adoc index 75eedfa6ce..a8e32fd61f 100644 --- a/articles/flow/advanced/browser-access.adoc +++ b/articles/flow/advanced/browser-access.adoc @@ -35,7 +35,8 @@ UI.getCurrent().getPage().fetchCurrentURL(currentUrl -> { During the initial HTTP request, Vaadin reads the user-agent information supplied by the browser and stores them in a [classname]`WebBrowser` instance, which is accessible from the current [classname]`VaadinSession`. -.Getting the browser object +Here’s an example how to get the `WebBrowser` instance and access some of the user-agent information: + [source,java] ---- WebBrowser browser = VaadinSession.getCurrent().getBrowser();