wicket.protocol.http
Class WebApplication

java.lang.Object
  extended bywicket.Application
      extended bywicket.protocol.http.WebApplication
Direct Known Subclasses:
MockWebApplication

public abstract class WebApplication
extends Application

A web application is a subclass of Application which associates with an instance of WicketServlet to serve pages over the HTTP protocol. This class is intended to be subclassed by framework clients to define a web application.

Application settings are given defaults by the WebApplication() constructor, such as error page classes appropriate for HTML. WebApplication subclasses can override these values and/or modify other application settings in their respective constructors by calling getSettings() to retrieve a mutable ApplicationSettings object.

If you want to use servlet specific configuration, e.g. using init parameters from the ServletConfigobject, you should override the init() method. For example:

 
       public void init()
       {
           String webXMLParameter = getWicketServlet()
               .getInitParameter("myWebXMLParameter");
           URL schedulersConfig = getWicketServlet().getServletContext()
               .getResource("/WEB-INF/schedulers.xml");
           ...
  
 

Author:
Jonathan Locke, Chris Turner
See Also:
WicketServlet, ApplicationSettings, ApplicationPages

Constructor Summary
WebApplication()
          Constructor.
 
Method Summary
 void addRedirect(javax.servlet.http.HttpServletRequest request, java.lang.String requestUri, BufferedResponse renderedResponse)
           
 ApplicationSettings createApplicationSettings()
          Subclasses could override this to give there own implementation of ApplicationSettings.
 BufferedResponse getBufferedResponse(javax.servlet.http.HttpServletRequest request, java.lang.String requestUri)
          Returns the redirect map where the buffered render pages are stored in.
(package private)  WebSession getSession(WebRequest request, boolean create)
          Gets a WebSession object from the HttpServletRequest, creating a new one if it doesn't already exist.
protected  ISessionFactory getSessionFactory()
           
 WicketServlet getWicketServlet()
           
protected  void init()
          Initialize; if you need the wicket servlet for initialization, e.g.
protected  void internalDestroy()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
protected  void internalInit()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
protected  WebRequest newWebRequest(javax.servlet.http.HttpServletRequest servletRequest)
          Create a new WebRequest.
protected  WebResponse newWebResponse(javax.servlet.http.HttpServletResponse servletResponse)
          Create a WebResponse.
 void setSessionFactory(ISessionFactory sessionFactory)
           
 void setWicketServlet(WicketServlet wicketServlet)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 
Methods inherited from class wicket.Application
addResourceFactory, get, getComponentResolvers, getConverterFactory, getLocalizer, getMarkupCache, getName, getPages, getPageSets, getResourceFactory, getResourceStreamLocator, getResourceWatcher, getSettings, getSharedResources, newCrypt, newMarkupParser, onRuntimeException, set, setLocalizer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebApplication

public WebApplication()
Constructor.

Method Detail

getWicketServlet

public final WicketServlet getWicketServlet()
Returns:
The Wicket servlet for this application

setSessionFactory

public final void setSessionFactory(ISessionFactory sessionFactory)
Parameters:
sessionFactory - The session factory to use

setWicketServlet

public final void setWicketServlet(WicketServlet wicketServlet)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Parameters:
wicketServlet - The wicket servlet instance for this application
Throws:
java.lang.IllegalStateException - If an attempt is made to call this method once the wicket servlet has been set for the application.

getSessionFactory

protected ISessionFactory getSessionFactory()
Specified by:
getSessionFactory in class Application
Returns:
Factory for creating sessions
See Also:
Application.getSessionFactory()

init

protected void init()
Initialize; if you need the wicket servlet for initialization, e.g. because you want to read an initParameter from web.xml or you want to read a resource from the servlet's context path, you can override this method and provide custom initialization. This method is called right after this application class is constructed, and the wicket servlet is set.

Overrides:
init in class Application

internalInit

protected void internalInit()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. Internal intialization. Reads servlet init parameter "configuration". If the parameter is "development", settings appropriate for development are set. If it's "deployment", deployment settings are used. If development configuration is specified and a "sourceFolder" init parameter is also set, then resources in that folder will be polled for changes.

Overrides:
internalInit in class Application

internalDestroy

protected void internalDestroy()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.


getSession

final WebSession getSession(WebRequest request,
                            boolean create)
Gets a WebSession object from the HttpServletRequest, creating a new one if it doesn't already exist.

Parameters:
request - The http request object
create - Should the session be created if not there.
Returns:
The session object

newWebRequest

protected WebRequest newWebRequest(javax.servlet.http.HttpServletRequest servletRequest)
Create a new WebRequest. Subclasses of WebRequest could e.g. decode and obfuscated URL which has been encoded by an appropriate WebResponse.

Parameters:
servletRequest -
Returns:
a WebRequest object

newWebResponse

protected WebResponse newWebResponse(javax.servlet.http.HttpServletResponse servletResponse)
Create a WebResponse. Subclasses of WebRequest could e.g. encode wicket's default URL and hide the details from the user. A appropriate WebRequest must be implemented and configured to decode the encoded URL.

Parameters:
servletResponse -
Returns:
a WebResponse object

getBufferedResponse

public BufferedResponse getBufferedResponse(javax.servlet.http.HttpServletRequest request,
                                            java.lang.String requestUri)
Returns the redirect map where the buffered render pages are stored in.

Parameters:
request -
requestUri -
Returns:
The Redirect map or null when there are no redirects.

addRedirect

public void addRedirect(javax.servlet.http.HttpServletRequest request,
                        java.lang.String requestUri,
                        BufferedResponse renderedResponse)
Parameters:
request -
requestUri -
renderedResponse -

createApplicationSettings

public ApplicationSettings createApplicationSettings()
Subclasses could override this to give there own implementation of ApplicationSettings. DO NOT CALL THIS METHOD YOURSELF. Use getSettings instead.

Overrides:
createApplicationSettings in class Application
Returns:
An instanceof an ApplicaitonSettings class
See Also:
Application.createApplicationSettings()


Copyright © 2004-2006 Wicket developers. All Rights Reserved.