public class Page extends Object implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static interface |
Page.ExecutionCanceler
Deprecated.
superseded by
PendingJavaScriptResult |
static interface |
Page.ExtendedClientDetailsReceiver
Callback for receiving extended client-side details.
|
| Constructor and Description |
|---|
Page(UI ui)
Creates a page instance for the given UI.
|
| Modifier and Type | Method and Description |
|---|---|
Registration |
addBrowserWindowResizeListener(BrowserWindowResizeListener resizeListener)
Adds a new
BrowserWindowResizeListener to this UI. |
void |
addHtmlImport(String url)
Adds the given HTML import to the page and ensures that it is loaded
successfully.
|
void |
addHtmlImport(String url,
LoadMode loadMode)
Adds the given HTML import to the page and ensures that it is loaded
successfully.
|
void |
addJavaScript(String url)
Adds the given JavaScript to the page and ensures that it is loaded
successfully.
|
void |
addJavaScript(String url,
LoadMode loadMode)
Adds the given JavaScript to the page and ensures that it is loaded
successfully.
|
void |
addJsModule(String url)
Adds the given JavaScript module to the page and ensures that it is
loaded successfully.
|
void |
addJsModule(String url,
LoadMode loadMode)
Adds the given JavaScript module to the page and ensures that it is
loaded successfully.
|
void |
addStyleSheet(String url)
Adds the given style sheet to the page and ensures that it is loaded
successfully.
|
void |
addStyleSheet(String url,
LoadMode loadMode)
Adds the given style sheet to the page and ensures that it is loaded
successfully.
|
Page.ExecutionCanceler |
executeJavaScript(String expression,
Serializable... parameters)
Deprecated.
Use
executeJs(String,Serializable...) instead since
it also allows getting return value back. |
PendingJavaScriptResult |
executeJs(String expression,
Serializable... parameters)
Asynchronously runs the given JavaScript expression in the browser.
|
History |
getHistory()
Gets a representation of
window.history for this page. |
void |
open(String url)
Opens the given url in a new tab.
|
void |
reload()
Reloads the page in the browser.
|
void |
retrieveExtendedClientDetails(Page.ExtendedClientDetailsReceiver receiver)
Obtain extended client side details, such as time screen and time zone
information, via callback.
|
void |
setLocation(String uri)
Navigates this page to the given URI.
|
void |
setLocation(URI uri)
Navigates this page to the given URI.
|
void |
setTitle(String title)
Sets the page title.
|
public Page(UI ui)
ui - the UI that this page instance is connected topublic void setTitle(String title)
To clear the page title, use an empty string.
title - the page title to set, not nullpublic void addStyleSheet(String url)
Relative URLs are interpreted as relative to the configured
frontend directory location. You can prefix the URL with
context:// to make it relative to the context path or use an
absolute URL to refer to files outside the frontend directory.
For component related style sheet dependencies, you should use the
@StyleSheet annotation.
Is is guaranteed that style sheet will be loaded before the first page
load. For more options, refer to addStyleSheet(String, LoadMode)
url - the URL to load the style sheet from, not nullpublic void addStyleSheet(String url, LoadMode loadMode)
Relative URLs are interpreted as relative to the configured
frontend directory location. You can prefix the URL with
context:// to make it relative to the context path or use an
absolute URL to refer to files outside the frontend directory.
For component related style sheet dependencies, you should use the
@StyleSheet annotation.
url - the URL to load the style sheet from, not nullloadMode - determines dependency load mode, refer to LoadMode for
detailspublic void addJavaScript(String url)
Relative URLs are interpreted as relative to the configured
frontend directory location. You can prefix the URL with
context:// to make it relative to the context path or use an
absolute URL to refer to files outside the frontend directory.
For component related JavaScript dependencies, you should use the
@JavaScript annotation.
Is is guaranteed that script will be loaded before the first page load.
For more options, refer to addJavaScript(String, LoadMode)
url - the URL to load the JavaScript from, not nullpublic void addJavaScript(String url, LoadMode loadMode)
Relative URLs are interpreted as relative to the configured
frontend directory location. You can prefix the URL with
context:// to make it relative to the context path or use an
absolute URL to refer to files outside the frontend directory.
For component related JavaScript dependencies, you should use the
@JavaScript annotation.
url - the URL to load the JavaScript from, not nullloadMode - determines dependency load mode, refer to LoadMode for
detailspublic void addJsModule(String url)
For component related JsModule dependencies, you should use the
@JsModule annotation.
Is is guaranteed that script will be loaded before the first page load.
For more options, refer to addJsModule(String, LoadMode)
url - the URL to load the JavaScript from, not nullpublic void addJsModule(String url, LoadMode loadMode)
For component related JavaScript dependencies, you should use the
@JsModule annotation.
url - the URL to load the JavaScript from, not nullloadMode - determines dependency load mode, refer to LoadMode for
detailspublic void addHtmlImport(String url)
Relative URLs are interpreted as relative to the configured
frontend directory location. You can prefix the URL with
context:// to make it relative to the context path or use an
absolute URL to refer to files outside the frontend directory.
Is is guaranteed that html import will be loaded before the first page
load. For more options, refer to addHtmlImport(String, LoadMode)
url - the URL to load the HTML import from, not nullpublic void addHtmlImport(String url, LoadMode loadMode)
Relative URLs are interpreted as relative to the configured
frontend directory location. You can prefix the URL with
context:// to make it relative to the context path or use an
absolute URL to refer to files outside the frontend directory.
url - the URL to load the HTML import from, not nullloadMode - determines dependency load mode, refer to LoadMode for
details@Deprecated public Page.ExecutionCanceler executeJavaScript(String expression, Serializable... parameters)
executeJs(String,Serializable...) instead since
it also allows getting return value back.$0, $1, and so on. Supported parameter types
are:
String
Integer
Double
Boolean
JsonValue
Element (will be sent as null if the server-side
element instance is not attached when the invocation is sent to the
client)
'prefix' + $0 instead of 'prefix$0' and
value[$0] instead of value.$0 since JavaScript
variables aren't evaluated inside strings or property names.expression - the JavaScript expression to invokeparameters - parameters to pass to the expressionpublic PendingJavaScriptResult executeJs(String expression, Serializable... parameters)
It is possible to get access to the return value of the execution by registering a handler with the returned pending result. If no handler is registered, the return value will be ignored.
The given parameters will be available to the expression as variables
named $0, $1, and so on. Supported parameter
types are:
String
Integer
Double
Boolean
JsonValue
Element (will be sent as null if the server-side
element instance is not attached when the invocation is sent to the
client)
'prefix' + $0 instead of 'prefix$0' and
value[$0] instead of value.$0 since JavaScript
variables aren't evaluated inside strings or property names.expression - the JavaScript expression to invokeparameters - parameters to pass to the expressionpublic History getHistory()
window.history for this page.public void reload()
public Registration addBrowserWindowResizeListener(BrowserWindowResizeListener resizeListener)
BrowserWindowResizeListener to this UI. The listener
will be notified whenever the browser window within which this UI resides
is resized.resizeListener - the listener to add, not nullBrowserWindowResizeListener.browserWindowResized(BrowserWindowResizeEvent),
Registrationpublic void open(String url)
url - the URL to open.public void setLocation(String uri)
uri - the URI to showpublic void setLocation(URI uri)
uri - the URI to showpublic void retrieveExtendedClientDetails(Page.ExtendedClientDetailsReceiver receiver)
receiver - the callback to which the details are providedCopyright © 2000–2019 Vaadin Ltd. All rights reserved.