|
Page Edited :
WICKET :
Lifecycle of a Wicket Application
Lifecycle of a Wicket Application has been edited by Gwyn Evans (Nov 06, 2006). Content:Table of contents The Life-Cycle of a Wicket ApplicationLoading the ApplicationA Wicket application runs in any J2EE compliant application server by <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>My Wicket Application</display-name> <servlet> <servlet-name>HelloWorldApplication</servlet-name> <servlet-class>wicket.protocol.http.WicketServlet</servlet-class> <init-param> <param-name>applicationClassName</param-name> <param-value>wicket.examples.helloworld.HelloWorldApplication</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>HelloWorldApplication</servlet-name> <url-pattern>/helloworld/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> The servlet-class specified will always be "wicket.protocol.http.WicketServlet". When WicketServlet is loaded, it will use this information to instantiate a single Servicing a RequestThe following three steps occur each time that WicketServlet handles a 1. Wicket asks the Application class to create a Session for the 2. The Session returned by the Application is asked to create a 3. The RequestCycle's request() method is called to handle the request. How RequestCycle Handles a RequestFor each request, a RequestCycle object does the following 3 things: 1. Calls the overridable method onBeginRequest() to allow RequestCycle 2. Parses the request and potentially invokes user request handling 3. Calls the overridable method onEndRequest() to allow RequestCycle Step 2 may involve some pretty sophisticated logic. When a request How Page Handles a RequestPage.request(), called in step 2 above, performs the following 3 1. Calls onBeginRequest() for every Component on the Page, giving each 2. Renders the Page by calling Page.render(). 3. If the Application for the Page has component checking enabled in 4. Calls onEndRequest() for every Component on the Page. Once step 2 begins (the render phase for the Page), the Page becomes ClusteringWhen a Page is replicated from one machine in a cluster to another, Model ChangesWhen models or model values are changed in Wicket by a call to Because Wicket cannot always know if a model has changed, you can help RenderingA Page renders itself by rendering its associated markup (the html If no component can be retrieved for a given id in the markup stream, Component.render() follows these steps to render a component: 1. Determine component visibility. If the component is not visible, 2. Component.onRender() is called to allow the Component's rendering 3. Any Component models are detached to reduce the size of the The implementation of onRender() can really be anything that writes to protected void onRender()
{
renderAll(findMarkupStream());
}
onRender() in WebComponent and WebMarkupContainer calls a different method that is tuned to rendering reusable components rather than containers full of arbitrary markup: protected void onRender()
{
renderComponent(findMarkupStream());
}
markup stream for the component and calls onComponentTag(Tag) to allow the subclass to modify the tag. Once the subclass has changed the tag, it is written out to the Response with renderComponentTag(Tag) and the markup stream is advanced to the next tag. Next onComponentTagBody() is called, passing in the MarkupStream and the ComponentTag that was written out as the opening tag. This allows the component to do whatever it needs to do to produce a body for the component tag. One operation the subclass can call in onComponentTagBody() is Component.replaceComponentTagBody(), which replaces the markup inside the component's body with an arbtirary String. Finally, the framework writes out any appropriate closing tag for the component's open tag. |
Unsubscribe or edit your notifications preferences
