...
The rendering of each component is divided into a number of phases, illustrated below.
Each of the orange phases (SetupRender, BeginRender, BeforeRenderBody, etc.) corresponds to an annotation you may place on one or more methods of your class. The annotation directs Tapestry to invoke your method as part of that phase.
...
All Render phase methods are optional; a default behavior is associated with each phase.
Annotation | Method Name | When Called |
---|---|---|
setupRender() | When initial setup actions, if any, are needed | |
beginRender() | When Tapestry is ready for the component's start tag, if any, to be rendered | |
beforeRenderTemplate() | Before Tapestry renders the component's template, if any | |
beforeRenderBody() | Before Tapestry renders the body of the component, if any | |
afterRenderBody() | After Tapestry renders the body of the component, if any, but before the rest of the component's template is rendered | |
afterRenderTemplate() | After Tapestry finishes rendering the component's template, if any | |
afterRender() | After Tapestry has finished rendering both the template and body of the component | |
cleanupRender() | When final cleanup actions, if any, are needed |
The large number of phases reflects the need for precise control of components from component mixins. Several of the phases exist almost exclusively for mixins.
...
What's really mind blowing is that the template and body of a component will often contain ... more components! That means that many different components will be in different phases of their own state machine.
Render Phases in Detail
...
Note |
---|
The SetupRender phase, like all render phases, occurs once for each rendering of the component. If the component is inside a looping component (Loop, Grid, etc.), then the SetupRender method will be called once for each iteration of the loop. |
SetupRender
The SetupRender phase (see @SetupRender) is where you can perform any one-time per-render setup for your component. This is a good place to read component parameters and use them to set temporary instance variables.
...
Code Block |
---|
http://www.example.com/myapp/mypage?t:component-trace=true |
Scrollbar |
---|