Package com.vaadin.flow.component.page
Class ExtendedClientDetails
java.lang.Object
com.vaadin.flow.component.page.ExtendedClientDetails
- All Implemented Interfaces:
Serializable
Provides extended information about the web browser, such as screen
resolution and time zone.
Please note that all information is fetched only once, and not updated
automatically. To retrieve updated values, you can execute JS with
Page.executeJs(String, Serializable...) and get the current value
back.
- Since:
- 2.0
- Author:
- Vaadin Ltd
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintGets the height of the body element in the document in pixels.intGets the width of the body element in the document in pixels.Returns the current date and time of the browser.doubleGets the device pixel ratio,window.devicePixelRatio.intReturns the offset in milliseconds between the browser's GMT TimeZone and DST.intReturns the browser-reported TimeZone offset in milliseconds from GMT ignoring possible daylight saving adjustments that may be in effect in the browser.intGets the height of the screen in pixels.intGets the width of the screen in pixels.Returns the TimeZone Id (like "Europe/Helsinki") provided by the browser (if the browser supports this feature).intReturns the browser-reported TimeZone offset in milliseconds from GMT.intGets the inner height of the browser windowwindow.innerHeightin pixels.intGets the inner width of the browser windowwindow.innerWidthin pixels.Returns a unique browser window identifier.booleanReturns whether daylight saving time (DST) is currently in effect in the region of the browser or not.booleanisIOS()Check if the browser is run on IOS.booleanisIPad()Check if the browser is run on IPad.booleanChecks if the browser supports touch events.
-
Method Details
-
getScreenWidth
public int getScreenWidth()Gets the width of the screen in pixels. This is the full screen resolution and not the width available for the application.- Returns:
- the width of the screen in pixels.
-
getScreenHeight
public int getScreenHeight()Gets the height of the screen in pixels. This is the full screen resolution and not the height available for the application.- Returns:
- the height of the screen in pixels.
-
getWindowInnerHeight
public int getWindowInnerHeight()Gets the inner height of the browser windowwindow.innerHeightin pixels. This includes the scrollbar, if it is visible.- Returns:
- the browser window inner height in pixels
-
getWindowInnerWidth
public int getWindowInnerWidth()Gets the inner width of the browser windowwindow.innerWidthin pixels. This includes the scrollbar, if it is visible.- Returns:
- the browser window inner width in pixels
-
getBodyClientHeight
public int getBodyClientHeight()Gets the height of the body element in the document in pixels.- Returns:
- the height of the body element
-
getBodyClientWidth
public int getBodyClientWidth()Gets the width of the body element in the document in pixels.- Returns:
- the width of the body element
-
getTimezoneOffset
public int getTimezoneOffset()Returns the browser-reported TimeZone offset in milliseconds from GMT. This includes possible daylight saving adjustments, to figure out which TimeZone the user actually might be in, seegetRawTimezoneOffset().- Returns:
- timezone offset in milliseconds, 0 if not available
- See Also:
-
getTimeZoneId
Returns the TimeZone Id (like "Europe/Helsinki") provided by the browser (if the browser supports this feature).- Returns:
- the TimeZone Id if provided by the browser, null otherwise.
- See Also:
-
getRawTimezoneOffset
public int getRawTimezoneOffset()Returns the browser-reported TimeZone offset in milliseconds from GMT ignoring possible daylight saving adjustments that may be in effect in the browser.You can use this to figure out which TimeZones the user could actually be in by calling
TimeZone.getAvailableIDs(int).If
getRawTimezoneOffset()andgetTimezoneOffset()returns the same value, the browser is either in a zone that does not currently have daylight saving time, or in a zone that never has daylight saving time.- Returns:
- timezone offset in milliseconds excluding DST, 0 if not available
-
getDSTSavings
public int getDSTSavings()Returns the offset in milliseconds between the browser's GMT TimeZone and DST.- Returns:
- the number of milliseconds that the TimeZone shifts when DST is in effect
-
isDSTInEffect
public boolean isDSTInEffect()Returns whether daylight saving time (DST) is currently in effect in the region of the browser or not.- Returns:
- true if the browser resides at a location that currently is in DST
-
getCurrentDate
Returns the current date and time of the browser. This will not be entirely accurate due to varying network latencies, but should provide a close-enough value for most cases. Also note that the returned Date object uses servers default time zone, not the clients.To get the actual date and time shown in the end users computer, you can do something like:
WebBrowser browser = ...; SimpleTimeZone timeZone = new SimpleTimeZone(browser.getTimezoneOffset(), "Fake client time zone"); DateFormat format = DateFormat.getDateTimeInstance(); format.setTimeZone(timeZone); myLabel.setValue(format.format(browser.getCurrentDate()));
- Returns:
- the current date and time of the browser.
- See Also:
-
isTouchDevice
public boolean isTouchDevice()Checks if the browser supports touch events.- Returns:
- true if the browser is detected to support touch events, false otherwise
-
getDevicePixelRatio
public double getDevicePixelRatio()Gets the device pixel ratio,window.devicePixelRatio. See more from MDN web docs.A value of -1 indicates that the value was not reported by the browser correctly.
- Returns:
- double-precision floating-point value indicating the ratio of the display's resolution in physical pixels to the resolution in CSS pixels
-
getWindowName
Returns a unique browser window identifier. For internal use only.- Returns:
- An id which persists if the UI is reloaded in the same browser window/tab.
-
isIPad
public boolean isIPad()Check if the browser is run on IPad.- Returns:
- true if run on IPad false if the user is not using IPad or if no information from the browser is present
-
isIOS
public boolean isIOS()Check if the browser is run on IOS.- Returns:
trueif run on IOS ,falseif the user is not using IOS or if no information from the browser is present
-