public class Page extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static interface |
Page.ExecutionCanceler
Callback method for canceling executable javascript set with
executeJavaScript(String, Serializable...) . |
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 |
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)
Asynchronously runs the given JavaScript expression in the browser.
|
History |
getHistory()
Gets a representation of
window.history for this page. |
void |
reload()
Reloads the page in the browser.
|
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 null
public 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 null
public 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 null
loadMode
- 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 null
public 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 null
loadMode
- 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 null
public 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 null
loadMode
- determines dependency load mode, refer to LoadMode
for
detailspublic Page.ExecutionCanceler executeJavaScript(String expression, Serializable... parameters)
$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 null
BrowserWindowResizeListener.browserWindowResized(BrowserWindowResizeEvent)
,
Registration
Copyright © 2019. All rights reserved.