Tapestry component and page classes may implement optional listener interfaces . This interfaces allow the component (or page) to be notified when certain lifecycle events occur. Each interface consists of a single method.
It is merely necessary to implement the interface; the framework will automatically register the component (or page) to receive the notification. It is perfectly acceptible to implement multiple interfaces.
|PageAttachListener||When a page is first attached to the current request. After the page's persistent properties have been rolled back.||Set up the page's properties based on the current session state, possibly by pulling data from an application state object .|
|PageValidateListener||When a page is activated (selected to render the reponse). Throw PageRedirectException to activate a different page.||Typically, checking the user's allowed access to a page, based on application-specific security rules.|
|PageBeginRenderListener||Just before the page begins to render. This is the last chance to update persistent page properties.|
|PageEndRenderListener||At the end of the page render (even if an exception is thrown while the page renders).|
|PageDetachListener||As the page is detached from the request and returned to the shared page pool.||Final cleanups to "scrub" the page, remove any client-specific state, and otherwise return it to a pristine state.|
Tapestry 3.0 defined a single PageRenderListener interface instead of PageBeginRenderListener and PageEndRenderListener . This is still supported in 4.0 (it has been redefined as extending the other two interfaces), but will likely be removed in a future release.