com.vaadin.flow.component.page.
Class Page
- java.lang.Object
-
- com.vaadin.flow.component.page.Page
-
All Implemented Interfaces:
public class Page extends Object implements Serializable
Represents the web page open in the browser, containing the UI it is connected to.
Since:
1.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static interface
Page.ExecutionCanceler
Callback method for canceling executable javascript set with
executeJavaScript(String, Serializable...)
.
-
Constructor Summary
Constructors Constructor and Description Page(UI ui)
Creates a page instance for the given UI.
-
Method Summary
All Methods Modifier and Type Method and Description 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.
-
-
-
Constructor Detail
-
Page
public Page(UI ui)
Creates a page instance for the given UI.
Parameters:
ui
- the UI that this page instance is connected to
-
-
Method Detail
-
setTitle
public void setTitle(String title)
Sets the page title. The title is displayed by the browser e.g. as the title of the browser window or tab.
To clear the page title, use an empty string.
Parameters:
title
- the page title to set, notnull
-
addStyleSheet
public void addStyleSheet(String url)
Adds the given style sheet to the page and ensures that it is loaded successfully.
Relative URLs are interpreted as relative to the configured
frontend
directory location. You can prefix the URL withcontext://
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)
Parameters:
url
- the URL to load the style sheet from, notnull
-
addStyleSheet
public void addStyleSheet(String url, LoadMode loadMode)
Adds the given style sheet to the page and ensures that it is loaded successfully.
Relative URLs are interpreted as relative to the configured
frontend
directory location. You can prefix the URL withcontext://
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.Parameters:
url
- the URL to load the style sheet from, notnull
loadMode
- determines dependency load mode, refer toLoadMode
for details
-
addJavaScript
public void addJavaScript(String url)
Adds the given JavaScript to the page and ensures that it is loaded successfully.
Relative URLs are interpreted as relative to the configured
frontend
directory location. You can prefix the URL withcontext://
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)
Parameters:
url
- the URL to load the JavaScript from, notnull
-
addJavaScript
public void addJavaScript(String url, LoadMode loadMode)
Adds the given JavaScript to the page and ensures that it is loaded successfully.
Relative URLs are interpreted as relative to the configured
frontend
directory location. You can prefix the URL withcontext://
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.Parameters:
url
- the URL to load the JavaScript from, notnull
loadMode
- determines dependency load mode, refer toLoadMode
for details
-
addHtmlImport
public void addHtmlImport(String url)
Adds the given HTML import to the page and ensures that it is loaded successfully.
Relative URLs are interpreted as relative to the configured
frontend
directory location. You can prefix the URL withcontext://
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)
Parameters:
url
- the URL to load the HTML import from, notnull
-
addHtmlImport
public void addHtmlImport(String url, LoadMode loadMode)
Adds the given HTML import to the page and ensures that it is loaded successfully.
Relative URLs are interpreted as relative to the configured
frontend
directory location. You can prefix the URL withcontext://
to make it relative to the context path or use an absolute URL to refer to files outside the frontend directory.Parameters:
url
- the URL to load the HTML import from, notnull
loadMode
- determines dependency load mode, refer toLoadMode
for details
-
executeJavaScript
public Page.ExecutionCanceler executeJavaScript(String expression, Serializable... parameters)
Asynchronously runs the given JavaScript expression in the browser. 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
Element
(will be sent asnull
if the server-side element instance is not attached when the invocation is sent to the client)
'prefix' + $0
instead of'prefix$0'
andvalue[$0]
instead ofvalue.$0
since JavaScript variables aren't evaluated inside strings or property names.Parameters:
expression
- the JavaScript expression to invokeparameters
- parameters to pass to the expressionReturns:
a callback for canceling the execution if not yet sent to browser
-
getHistory
public History getHistory()
Gets a representation of
window.history
for this page.Returns:
the history representation
-
reload
public void reload()
Reloads the page in the browser.
-
-