|
Page Edited :
WICKET :
Page rendering
Page rendering has been edited by syl (Nov 25, 2007). Content:Pages are asked to render themselves only by IRequestTargets (see Request targets). So the initial message renderPage() comes from a target instance. Page render initiates render of all its subcomponents and is responsible for calling render related methods. Since page extends MarkupContainer most of its render logic is applicable to any MarkupContainer. Page rendering consists of the following steps:
It worth mentioning that before those steps page restores values of all form components which can be persisted (see FormComponent#supportsPersistence()). These values can be restored from anywhere (see IValuePersister interface). By default they are restored from cookies. Page rendering
Before render stepBefore render step is responsible for:
Both of these actions will include only those components which are going to be rendered. That means invisible components will be skipped. Page doesn't go through all its subcomponents itself. As a MarkupContainer page handles only its immediate subcomponents with MarkupContainer#onBeforeRenderChildren() method which iterates components and calls Component#beforeRender() method for each of them. If subcomponent is a MarkupContainer, it does the same thing for all it subcomponents. Thus component tree is traversed. You can change component state and models during this step. RenderingBeing a Component page render itself as all other components by overriding Component#onRender() method. During the rendering page does the following:
The important thing about rendering is that it is markup driven. It means that components are rendered as corresponding tags appear in the markup stream. When there are no more tags in the markup stream rendering is over. This is how renderAll() method is implemented (note that component rendering code is responsible for advancing markup stream): protected void renderAll(final MarkupStream markupStream) { while (markupStream.hasMore()) { final int index = markupStream.getCurrentIndex();
renderNext(markupStream);
if (index == markupStream.getCurrentIndex())
{
markupStream.throwMarkupException("Component ... failed to advance the markup stream");
}
}
}
The renderNext() method belongs to MarkupContainer class and it is not used exclusively by pages. This method gets current tag from markup stream and attempts to find component which current markup tag corresponds to. Finding a component includes:
If component is found, it is asked to render itself by calling Component#render(MarkupStream) method (see Component rendering). Otherwise exception if thrown with a messages like "Unable to find component with id ... This means that you declared wicket:id ... in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match". You should not change component state or change model during this step. After renderAfter render step is similar to before render step. It includes:
Unlike before render step these actions will be applied for all components whether there are visible or not. As a MarkupContainer page calls MarkupContainer#onAfterRenderChildren() and process all of its immediate subcomponents. You should not change component state or change model during this step. |
Unsubscribe or edit your notifications preferences
