...
A Wicket application runs in any J2EE compliant application server by
defining a Java servlet filter in the application's web.xml
file:
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTFISO-8859-81"?> <!DOCTYPE web<web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" " xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/dtdjavaee/web-app_2_3.dtd5.xsd" version="2.5"> <web-app> <display-name>My Wicket Application</display-name> <servlet> <servlet-name>HelloWorldApplication</servlet-name> <servlet-class>wicket.protocol.http.WicketServlet</servlet-class> <display-name>wicketproject</display-name> <!-- There are three means to configure Wickets configuration mode and they are tested in the order given. 1) A system property: -Dwicket.configuration 2) servlet specific <init-param> 3) context specific <context-param> The value might be either "development" (reloading when templates change) or "deployment". If no configuration is found, "development" is the default. --> <filter> <filter-name>wicket.wicketproject</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value>wicketvalue>com.examplesyourcompany.helloworld.HelloWorldApplication<WicketApplication</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>filter> <servlet<filter-mapping> <servlet-name>HelloWorldApplication</servlet<filter-name>wicket.wicketproject</filter-name> <url-pattern>/helloworld/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> filter-mapping> </web-app> |
The servlet-filter class specified will always be "org.apache.wicket.protocol.http.
WicketServletWicketFilter
". The "applicationClassName
" init-param provided must be the name of a WebApplication
subclass. In the case above, it is "wicketcom.
examplesyourcompany.
helloworld.HelloWorldApplicationWicketApplication
".
When WicketServlet WicketFilter
is loaded, it will use this information to instantiate a single instance of your application class.
Servicing a Request
The following three steps occur each time that WicketServlet handles WicketFilter intercepts a request and a redirect is not required:
- it sets the application to the thread context
- the application creates a
WebRequest
,WebResponse
andRequestCycle
- the
RequestCycle
'sprocessRequestAndDetach
- Wicket asks the Application class to create a Session for the servlet request. If no session exists for the incoming request, a Session object is created using the application's session factory.
- The Session returned by the Application is asked to create a RequestCycle object using the Session's request cycle factory.
- The RequestCycle's
request()
method is called to handle the request.
How RequestCycle Handles a Request
...