|
Page Edited :
WICKET :
Request processing overview
Request processing overview has been edited by syl (Jan 16, 2008). Content:
At the risk of being unoriginal, request processing in general does two things: changes some data which is stored in HttpSession, database or somewhere else; creates some output which is usually HTML. These is no single class in Wicket that does all the request processing. Classes delegate the work to each other. In a simplified way it goes like this: Unable to render embedded object: File (request_processing(simple).jpg) not found.
There are more classes involved in request processing. Some of them are shown in the diagram below. The diagram is followed by short descriptions of each of these classes. Descriptions say what is the purpose of the class, when it is created and how to get its instance. It's also a good idea to take a look at these classes' javadocs. Relation between classes involved in request processing WicketFilter/ServletWhat for Creates and initializes application. Asks application to create request, response and request cycle objects. Starts request processing by calling request() method on RequestCycle. WebApplicationWhat for Application and WebApplication can be used to set up a lot of different things which in general may be called configuration. Most frequently used probably are:
Application and WebApplication also have some overridable methods:
Besides that application can be used for storing any user-defined application scope data. When created WebApplication is created when WicketFilter/Servlet is initialized. It is created by IWebApplicationFactory implementation. Factory can be specified in WicketFilter/Servlet configuration in the web.xml using applicationFactoryClassName parameter like this: <init-param> <param-name>applicationFactoryClassName</param-name> <param-value>org.apache.wicket.MyApplicationFactory</param-value> </init-param> You can implement IWebApplicationFactory which will create the application instance you want but usually it is not necessary. If there is no applicationFactoryClassName parameter in the web.xml, Wicket uses default factory implementation which reads applicationClassName parameter and creates application instance of the specified class using reflection.
For more information see Request cycle and request cycle processor When created There is one instance of IRequestCycleProcessor per Application. It is lazily created during the first request. Its creation can be customized by overriding WebApplication#newRequestCycleProcessor(). How to get Use WebApplication#getRequestCycleProcessor() method (you shouldn't need to do it). IRequestCodingStrategyWhat for In short IRequestCodingStrategy is responsible for converting URL to object representation and vice versa. It "decodes" incoming request and creates a RequestParameters object which is then passed to IRequestCycleProcessor to resolve target. IRequestCodingStrategy also has in some sense reverse method which "encodes" request targets, what means creating a URL for specified IRequestTarget. public interface IRequestCodingStrategy ... RequestParameters decode(Request request); CharSequence encode(RequestCycle requestCycle, IRequestTarget requestTarget); See also Request coding strategy page. When created There is one instance of IRequestCodingStrategy per IRequestCycleProcessor which is lazily created during the first request. Its creation can be customized by overriding AbstractRequestCycleProcessor#newRequestCodingStrategy(). How to get Get IRequestCycleProcessor instance and use IRequestCycleProcessor#getRequestCodingStrategy() method. IRequestTargetWhat for IRequestTarget contains Page/Component or knows how to create it. It is responsible for calling event handling code (like Form#onSubmit() method) and asking pages and components to render. When created IRequestTarget is created by IRequestCycleProcessor on every request and stored in RequestCycle. Which subclass of IRequestTarget will be created depends on RequestParameters instance which is decoded from requested URL. For example if a bookmarkable page is requested, BookmarkablePageRequestTarget is created; if a link is pressed, ListenerInterfaceRequestTarget is created. See also Request targets page. How to get You can get current request target from by getting RequestCycle instance and calling RequestCycle#getRequestTarget() method. WebRequest, WebResponseWhat for Basically WebRequest and wrap HttpServletRequest and HttpServletResponse classes. WebResponse is also used in components as an output for markup. When created They are created on every request by Application just before creating RequestCycle. See description for RequestCycle. How to get Get RequestCycle instance, use RequestCycle#getRequest/Response() method and cast returned object if exactly WebRequest/Response is needed. WebSessionWhat for WebSession holds information about a user session including some fixed number of most recent pages. WebSession roughly corresponds to HttpSession. When created It is lazily created during request handling. Then WebSession is stored in HttpSession and restored from there on next request. If HttpSession expires and WebSession in which is stored it can't be reached anymore new WebSession instance is created. To customize Session creation you can override Application#newSession() method. How to get You can get instance of Session using static Session#get() method. ISessionStoreWhat for "The actual store that is used by Session to store its attributes". It means that Session doesn't necessarily store data in HttpSession. When created There is one instance of ISessionStore which is created at Application creation. How to get Use Application#getSessionStore() method (you shouldn't need to do it). Page, ComponentWhat for Pages and Components are perhaps the most important part of all. It is the place where most of the user code resides. You should be able to do most of the things you may want to do in web-application without knowing anything else apart from Pages and Components (and perhaps a little bit about Application). Components generally do three things: See also Component hierarchy. When created Components are created "manually". Usually it happens in a page constructor. |
Unsubscribe or edit your notifications preferences
