Class PageImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.structure.PageImpl
-
- All Implemented Interfaces:
Page
,PageLifecycleCallbackHub
public class PageImpl extends Object implements Page
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.tapestry5.internal.structure.Page
Page.Stats
-
-
Constructor Summary
Constructors Constructor Description PageImpl(String name, ComponentResourceSelector selector, PersistentFieldManager persistentFieldManager, PerthreadManager perThreadManager, MetaDataLocator metaDataLocator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLifecycleListener(PageLifecycleListener listener)
Adds a listener that is notified of large scale page events.void
addPageAttachedCallback(Runnable callback)
Adds a callback for when the page is attached to the request.void
addPageDetachedCallback(Runnable callback)
Adds a callback for when the page is detached from the request.void
addPageLoadedCallback(Runnable callback)
Adds a callback for when the page is first loaded.void
addResetCallback(Runnable callback)
A reset occurs when a request for a page arrives that did not originate on the same page.void
addResetListener(PageResetListener listener)
Adds a new listener for page reset events.void
addVerifyCallback(Runnable callback)
Adds a verify callback, which is allowed while the page is loading.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 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, String fieldName, Object newValue)
Posts a change to a persistent field.void
removeLifecycleListener(PageLifecycleListener listener)
Removes a listener that was previously added.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.String
toString()
-
-
-
Constructor Detail
-
PageImpl
public PageImpl(String name, ComponentResourceSelector selector, PersistentFieldManager persistentFieldManager, PerthreadManager perThreadManager, MetaDataLocator metaDataLocator)
- Parameters:
name
- canonicalized page nameselector
- used to locate resourcespersistentFieldManager
- for access to cross-request persistent valuesperThreadManager
-metaDataLocator
-
-
-
Method Detail
-
setStats
public void setStats(Page.Stats stats)
Description copied from interface:Page
Invoked once at the end of page construction, to provide page construction statistics.
-
getStats
public Page.Stats getStats()
Description copied from interface:Page
Returns the page construction statistics for this page.
-
getComponentElementByNestedId
public ComponentPageElement getComponentElementByNestedId(String nestedId)
Description copied from interface:Page
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.- Specified by:
getComponentElementByNestedId
in interfacePage
-
getSelector
public ComponentResourceSelector getSelector()
Description copied from interface:Page
The selector (which includes Locale) used when the page was constructor.- Specified by:
getSelector
in interfacePage
-
setRootElement
public void setRootElement(ComponentPageElement component)
Description copied from interface:Page
Invoked during page construction time to connect the page's root component to the page instance.- Specified by:
setRootElement
in interfacePage
-
getRootElement
public ComponentPageElement getRootElement()
Description copied from interface:Page
The root component of the page. This is the wrapper around the end developer's view of the page.- Specified by:
getRootElement
in interfacePage
-
getRootComponent
public Component getRootComponent()
Description copied from interface:Page
The root component of the page. A convenience over invoking getRootElement().getComponent().- Specified by:
getRootComponent
in interfacePage
-
addLifecycleListener
public void addLifecycleListener(PageLifecycleListener listener)
Description copied from interface:Page
Adds a listener that is notified of large scale page events.- Specified by:
addLifecycleListener
in interfacePage
-
removeLifecycleListener
public void removeLifecycleListener(PageLifecycleListener listener)
Description copied from interface:Page
Removes a listener that was previously added.- Specified by:
removeLifecycleListener
in interfacePage
-
detached
public boolean detached()
Description copied from interface:Page
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.- Specified by:
detached
in interfacePage
- Returns:
- true if the page is "dirty", false otherwise
- See Also:
PageLifecycleListener.containingPageDidDetach()
-
loaded
public void loaded()
Description copied from interface:Page
Inform the page that it is now completely loaded.- Specified by:
loaded
in interfacePage
- See Also:
PageLifecycleListener.containingPageDidLoad()
-
attached
public void attached()
Description copied from interface:Page
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 toPage.loaded()
will preceded the call toPage.attached()
. First all listeners havePageLifecycleListener.restoreStateBeforePageAttach()
invoked, followed byPageLifecycleListener.containingPageDidAttach()
.
-
getLogger
public org.slf4j.Logger getLogger()
Description copied from interface:Page
Returns the logger of the root component element. Any logging about page construction or activity should be sent to this logger.
-
persistFieldChange
public void persistFieldChange(ComponentResources resources, String fieldName, Object newValue)
Description copied from interface:Page
Posts a change to a persistent field.- Specified by:
persistFieldChange
in interfacePage
- 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
public Object getFieldChange(String nestedId, String fieldName)
Description copied from interface:Page
Gets a change for a field within the component.- Specified by:
getFieldChange
in interfacePage
- 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
public void discardPersistentFieldChanges()
Description copied from interface:Page
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).- Specified by:
discardPersistentFieldChanges
in interfacePage
-
getName
public String getName()
Description copied from interface:Page
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).
-
addResetCallback
public void addResetCallback(Runnable callback)
Description copied from interface:PageLifecycleCallbackHub
A reset occurs when a request for a page arrives that did not originate on the same page. This gives the application a chance to reset the state of the page.- Specified by:
addResetCallback
in interfacePageLifecycleCallbackHub
- Parameters:
callback
- invoked when a page is activated by link from some other page.
-
addResetListener
public void addResetListener(PageResetListener listener)
Description copied from interface:Page
Adds a new listener for page reset events.- Specified by:
addResetListener
in interfacePage
- Parameters:
listener
- will receive notifications when the page is accessed from a different page
-
addVerifyCallback
public void addVerifyCallback(Runnable callback)
Description copied from interface:PageLifecycleCallbackHub
Adds a verify callback, which is allowed while the page is loading. Such callbacks are invoked once, after the page has been loaded successfully, and are then discarded. This was added specifically to ensure that components only verify that required parameters are bound after all components and mixins of the page have had a chance to initialize.- Specified by:
addVerifyCallback
in interfacePageLifecycleCallbackHub
- Parameters:
callback
- to be invoked after page loaded
-
pageReset
public void pageReset()
Description copied from interface:Page
Invoked to notifyPageResetListener
listeners.
-
hasResetListeners
public boolean hasResetListeners()
Description copied from interface:Page
Returns true if there are anyPageResetListener
listeners.- Specified by:
hasResetListeners
in interfacePage
-
getAttachCount
public int getAttachCount()
Description copied from interface:Page
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.- Specified by:
getAttachCount
in interfacePage
-
isExactParameterCountMatch
public boolean isExactParameterCountMatch()
Description copied from interface:Page
Returns true if extract parameter count matching is enabled.- Specified by:
isExactParameterCountMatch
in interfacePage
- See Also:
MetaDataConstants.UNKNOWN_ACTIVATION_CONTEXT_CHECK
-
addPageLoadedCallback
public void addPageLoadedCallback(Runnable callback)
Description copied from interface:PageLifecycleCallbackHub
Adds a callback for when the page is first loaded. Callbacks are invoked in the order they are added to the page. They are invoked once and then discarded.- Specified by:
addPageLoadedCallback
in interfacePageLifecycleCallbackHub
- Parameters:
callback
- invoked once, when page is first loaded
-
addPageAttachedCallback
public void addPageAttachedCallback(Runnable callback)
Description copied from interface:PageLifecycleCallbackHub
Adds a callback for when the page is attached to the request.- Specified by:
addPageAttachedCallback
in interfacePageLifecycleCallbackHub
-
addPageDetachedCallback
public void addPageDetachedCallback(Runnable callback)
Description copied from interface:PageLifecycleCallbackHub
Adds a callback for when the page is detached from the request.- Specified by:
addPageDetachedCallback
in interfacePageLifecycleCallbackHub
-
-