public abstract class PushPage extends Object
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
.
Modifier | Constructor and Description |
---|---|
protected |
PushPage()
Creates new PushPage .
|
Modifier and Type | Method and Description |
---|---|
static PushPage |
current() |
abstract DomElement |
document()
Renders the page, i.e.
|
ExecutorService |
executor()
Page's event loop.
|
PageFrame |
frame(long requestSeq) |
String |
pageId()
Globally unique page ID.
|
boolean |
poster()
Checks whether currently rendered frame is a poster frame.
|
ReactiveServletRequest |
request()
Initial request that opened this page.
|
void |
serve(ReactiveServletRequest request) |
void |
serve(ReactiveServletResponse response) |
void |
start() |
String |
toString() |
public ReactiveServletRequest request()
This method only reads immutable data.
public String pageId()
This method only reads immutable data.
@DraftApi(value="some way to specify the underlying thread pool") public ExecutorService executor()
This method only reads immutable data.
public abstract DomElement document()
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()
.
<html>
root tag.
@NoDocs public void serve(ReactiveServletRequest request)
@NoDocs public void serve(ReactiveServletResponse response)
public boolean poster()
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.
@NoDocs public void start()
@NoDocs @DraftApi(value="mind testability") public PageFrame frame(long requestSeq)
@NoDocs public static PushPage current()
Copyright © 2015–2021 Robert Važan. All rights reserved.