public interface Page extends PageLifecycleCallbackHub
root
component
of the actual page.
Starting in release 5.2, the nature of pages changed considerably. Pages are no longer pooled instances. Instead,
pages are shared instances (per locale) but all internal mutable state is stored inside
PerthreadManager
. Page construction time is considered to extend past the
page loaded callback. This is not quite perfect from a
threading point-of-view (arguably, even write-once-read-many fields should be protected by synchronized blocks or
other mechanisms). At best, we can be assured that the entire page construction phase is protected by a single
synchronized block (but not on the page itself). An ideal system would build the page bottom to top so that all
assignments could take place in constructors, assigning to final fields. Maybe some day.
The Page object is never visible to end-user code, though it exposes an interface (PageLifecycleCallbackHub
that
is).Modifier and Type | Interface and Description |
---|---|
static class |
Page.Stats
Page construction statistics for the page.
|
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(PageLifecycleListener listener)
|
void |
addResetListener(PageResetListener listener)
Deprecated.
in 5.3.4,
|
void |
attached()
Invoked to inform the page that it is attached to the current request.
|
boolean |
detached()
Invoked to inform the page that it is being detached from the current request.
|
void |
discardPersistentFieldChanges()
Discards all persistent field changes for the page containing the component.
|
int |
getAttachCount()
Returns the number of times the page has been attached to a request.
|
ComponentPageElement |
getComponentElementByNestedId(String nestedId)
Retrieves a component element by its nested id (a sequence of simple ids, separated by dots).
|
Object |
getFieldChange(String nestedId,
String fieldName)
Gets a change for a field within the component.
|
org.slf4j.Logger |
getLogger()
Returns the logger of the root component element.
|
String |
getName()
Returns the short, logical name for the page.
|
Component |
getRootComponent()
The root component of the page.
|
ComponentPageElement |
getRootElement()
The root component of the page.
|
ComponentResourceSelector |
getSelector()
The selector (which includes Locale) used when the page was constructor.
|
Page.Stats |
getStats()
Returns the page construction statistics for this page.
|
boolean |
hasResetListeners()
Returns true if there are any
PageResetListener listeners. |
boolean |
isExactParameterCountMatch()
Returns true if extract parameter count matching is enabled.
|
void |
loaded()
Inform the page that it is now completely loaded.
|
void |
pageReset()
Invoked to notify
PageResetListener listeners. |
void |
persistFieldChange(ComponentResources resources,
String fieldName,
Object newValue)
Posts a change to a persistent field.
|
void |
removeLifecycleListener(PageLifecycleListener listener)
Deprecated.
in 5.3.4, due to introduction of
PageLifecycleCallbackHub.addPageLoadedCallback(Runnable) |
void |
setRootElement(ComponentPageElement component)
Invoked during page construction time to connect the page's root component to the page
instance.
|
void |
setStats(Page.Stats stats)
Invoked once at the end of page construction, to provide page construction statistics.
|
addPageAttachedCallback, addPageDetachedCallback, addPageLoadedCallback, addResetCallback, addVerifyCallback
String getName()
ComponentResourceSelector getSelector()
void setRootElement(ComponentPageElement component)
ComponentPageElement getRootElement()
Component getRootComponent()
boolean detached()
PerthreadManager
. A future release of Tapestry will likely convert this method to
type void.PageLifecycleListener.containingPageDidDetach()
void attached()
loaded()
will preceded the call to attached()
.
First all listeners have PageLifecycleListener.restoreStateBeforePageAttach()
invoked, followed by
PageLifecycleListener.containingPageDidAttach()
.void loaded()
void addLifecycleListener(PageLifecycleListener listener)
PageLifecycleCallbackHub.addPageLoadedCallback(Runnable)
, PageLifecycleCallbackHub.addPageAttachedCallback(Runnable)
, or
PageLifecycleCallbackHub.addPageDetachedCallback(Runnable)
insteadvoid removeLifecycleListener(PageLifecycleListener listener)
PageLifecycleCallbackHub.addPageLoadedCallback(Runnable)
org.slf4j.Logger getLogger()
ComponentPageElement getComponentElementByNestedId(String nestedId)
UnknownValueException
- if the nestedId does not correspond to a componentvoid persistFieldChange(ComponentResources resources, String fieldName, Object newValue)
resources
- the component resources for the component or mixin containing the field whose
value changedfieldName
- the name of the fieldnewValue
- the new value for the fieldObject getFieldChange(String nestedId, String fieldName)
nestedId
- the nested component id of the component containing the fieldfieldName
- the name of the persistent fieldvoid discardPersistentFieldChanges()
Session
) which will
take effect in the next request (the attached page instance is not affected).void addResetListener(PageResetListener listener)
listener
- will receive notifications when the page is accessed from a different pageboolean hasResetListeners()
PageResetListener
listeners.void pageReset()
PageResetListener
listeners.void setStats(Page.Stats stats)
Page.Stats getStats()
int getAttachCount()
@NonVisual boolean isExactParameterCountMatch()
MetaDataConstants.UNKNOWN_ACTIVATION_CONTEXT_CHECK
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.