Interface Page
-
- All Superinterfaces:
PageLifecycleCallbackHub
- All Known Implementing Classes:
PageImpl
public interface Page extends PageLifecycleCallbackHub
Represents a unique page within the application. Pages are part of the internal structure of a Tapestry application; end developers who refer to "page" are really referring to theroot 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 insidePerthreadManager
. 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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Page.Stats
Page construction statistics for the page.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method 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(java.lang.String nestedId)
Retrieves a component element by its nested id (a sequence of simple ids, separated by dots).java.lang.Object
getFieldChange(java.lang.String nestedId, java.lang.String fieldName)
Gets a change for a field within the component.org.slf4j.Logger
getLogger()
Returns the logger of the root component element.java.lang.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 anyPageResetListener
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 notifyPageResetListener
listeners.void
persistFieldChange(ComponentResources resources, java.lang.String fieldName, java.lang.Object newValue)
Posts a change to a persistent field.void
removeLifecycleListener(PageLifecycleListener listener)
Deprecated.in 5.3.4, due to introduction ofPageLifecycleCallbackHub.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.-
Methods inherited from interface org.apache.tapestry5.runtime.PageLifecycleCallbackHub
addPageAttachedCallback, addPageDetachedCallback, addPageLoadedCallback, addResetCallback, addVerifyCallback
-
-
-
-
Method Detail
-
getName
java.lang.String getName()
Returns the short, logical name for the page. This is the page name as it might included in an action or page render URL (though it will be converted to lower case when it is included).
-
getSelector
ComponentResourceSelector getSelector()
The selector (which includes Locale) used when the page was constructor.
-
setRootElement
void setRootElement(ComponentPageElement component)
Invoked during page construction time to connect the page's root component to the page instance.
-
getRootElement
ComponentPageElement getRootElement()
The root component of the page. This is the wrapper around the end developer's view of the page.
-
getRootComponent
Component getRootComponent()
The root component of the page. A convenience over invoking getRootElement().getComponent().
-
detached
boolean detached()
Invoked to inform the page that it is being detached from the current request. This occurs just before the page is returned to the page pool. A page may be clean or dirty. A page is dirty if its dirty count is greater than zero (meaning that, during the render of the page, some components did not fully render), or if any of its listeners throw an exception from containingPageDidDetach(). The page pool should discard pages that are dirty, rather than store them into the pool. Under Tapestry 5.2 and pool-less pages, the result is ignored; all mutable state is expected to be discarded automatically from thePerthreadManager
. A future release of Tapestry will likely convert this method to type void.- Returns:
- true if the page is "dirty", false otherwise
- See Also:
PageLifecycleListener.containingPageDidDetach()
-
attached
void attached()
Invoked to inform the page that it is attached to the current request. This occurs when a page is first referenced within a request. If the page was created from scratch for this request, the call toloaded()
will preceded the call toattached()
. First all listeners havePageLifecycleListener.restoreStateBeforePageAttach()
invoked, followed byPageLifecycleListener.containingPageDidAttach()
.
-
loaded
void loaded()
Inform the page that it is now completely loaded.
-
addLifecycleListener
void addLifecycleListener(PageLifecycleListener listener)
Deprecated.Adds a listener that is notified of large scale page events.
-
removeLifecycleListener
void removeLifecycleListener(PageLifecycleListener listener)
Deprecated.in 5.3.4, due to introduction ofPageLifecycleCallbackHub.addPageLoadedCallback(Runnable)
Removes a listener that was previously added.- Since:
- 5.2.0
-
getLogger
org.slf4j.Logger getLogger()
Returns the logger of the root component element. Any logging about page construction or activity should be sent to this logger.
-
getComponentElementByNestedId
ComponentPageElement getComponentElementByNestedId(java.lang.String nestedId)
Retrieves a component element by its nested id (a sequence of simple ids, separated by dots). The individual names in the nested id are matched without regards to case. A nested id of '' (the empty string) returns the root element of the page.- Throws:
UnknownValueException
- if the nestedId does not correspond to a component
-
persistFieldChange
void persistFieldChange(ComponentResources resources, java.lang.String fieldName, java.lang.Object newValue)
Posts a change to a persistent field.- Parameters:
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 field
-
getFieldChange
java.lang.Object getFieldChange(java.lang.String nestedId, java.lang.String fieldName)
Gets a change for a field within the component.- Parameters:
nestedId
- the nested component id of the component containing the fieldfieldName
- the name of the persistent field- Returns:
- the value, or null if no value is stored
-
discardPersistentFieldChanges
void discardPersistentFieldChanges()
Discards all persistent field changes for the page containing the component. Changes are eliminated from persistent storage (such as theSession
) which will take effect in the next request (the attached page instance is not affected).
-
addResetListener
void addResetListener(PageResetListener listener)
Deprecated.in 5.3.4,Adds a new listener for page reset events.- Parameters:
listener
- will receive notifications when the page is accessed from a different page- Since:
- 5.2.0
-
hasResetListeners
boolean hasResetListeners()
Returns true if there are anyPageResetListener
listeners.- Since:
- 5.2.0
-
pageReset
void pageReset()
Invoked to notifyPageResetListener
listeners.
-
setStats
void setStats(Page.Stats stats)
Invoked once at the end of page construction, to provide page construction statistics.- Since:
- 5.3
-
getStats
Page.Stats getStats()
Returns the page construction statistics for this page.
-
getAttachCount
int getAttachCount()
Returns the number of times the page has been attached to a request. This is a rough measure of how important the page is, relative to other pages. This value is volatile, changing constantly.- Since:
- 5.3
-
isExactParameterCountMatch
@NonVisual boolean isExactParameterCountMatch()
Returns true if extract parameter count matching is enabled.- Since:
- 5.4
- See Also:
MetaDataConstants.UNKNOWN_ACTIVATION_CONTEXT_CHECK
-
-