PushPage
is the root of page's server-side object graph.
The recommended practice is to define one derived class for every distinct page on the site. It is often desirable to create one or more "master" pages and then derive specialized pages from them. Every derived class must at the very minimum define document()
method.
Whenever the user visits some page, corresponding PushPage
instance is created. Instances of PushPage
live for as long as the user keeps the page open (i.e. while keepalive messages keep coming) and some time after that to account for temporary connection loss.
Every PushPage
has an associated PageExecutor
that can be obtained from executor()
method. All page renders (executions of document()
), DOM events, and DOM bindings are scheduled on the PageExecutor
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic PushPage
current()
abstract DomElement
document()
Renders the page, i.e.executor()
Page's event loop.frame
(long requestSeq) pageId()
Globally unique page ID.boolean
poster()
Checks whether currently rendered frame is a poster frame.request()
Initial request that opened this page.void
serve
(ReactiveServletRequest request) void
serve
(ReactiveServletResponse response) void
start()
toString()
-
Constructor Details
-
PushPage
protected PushPage()
-
-
Method Details
-
request
Initial request that opened this page.This method only reads immutable data.
- Returns:
- Page's initial HTTP request.
-
pageId
Globally unique page ID. Page IDs are produced by secure cryptographic random number generator. They never repeat.This method only reads immutable data.
- Returns:
- Page ID as a string matching regex [a-zA-Z0-9]+.
-
executor
Page's event loop. All page renders and all DOM events and bindings run in this event loop.This method only reads immutable data.
- Returns:
- Page's event loop.
-
document
Renders the page, i.e. generates DOM tree of the page. Override this method to define HTML content of the page.This method is called as part of page's reactive computation, i.e. its dependencies are tracked and it is re-run every time its dependencies change.
This method is run by page's
executor()
.- Returns:
-
Page's DOM tree with
<html>
root tag.
-
serve
-
serve
-
poster
public boolean poster()Checks whether currently rendered frame is a poster frame.Poster frame is sent as vanilla HTML to the browser in response to initial HTTP request. Usually only the first frame of the page is a poster frame, but draft frames may cause the poster frame to be rendered several times.
Application code can call this method from within
document()
method. It is useful for rendering slightly different content in the poster frame, perhaps to deal with bots or to enable events in a more controlled fashion.This method accesses reactive data. It will cause reactive computations to re-evaluate when the reactive data changes.
This method is safe to call from any thread.
- Returns:
- True if rendering poster frame.
-
toString
-
start
-
frame
-
current
-