org.apache.wicket.protocol.http
Class WebRequestCycle

java.lang.Object
  extended by org.apache.wicket.RequestCycle
      extended by org.apache.wicket.protocol.http.WebRequestCycle
Direct Known Subclasses:
WicketExampleRequestCycle

public class WebRequestCycle
extends RequestCycle

RequestCycle implementation for HTTP protocol. Holds the application, session, request and response objects for a given HTTP request. Contains methods (urlFor*) which yield a URL for bookmarkable pages as well as non-bookmarkable component interfaces. The protected handleRender method is the internal entrypoint which takes care of the details of rendering a response to an HTTP request.

Author:
Jonathan Locke, Johan Compagner, Gili Tzabari, Eelco Hillenius
See Also:
RequestCycle

Field Summary
 
Fields inherited from class org.apache.wicket.RequestCycle
application, processor, request, response
 
Constructor Summary
WebRequestCycle(WebApplication application, WebRequest request, Response response)
          Constructor which simply passes arguments to superclass for storage there.
 
Method Summary
 IRequestCycleProcessor getProcessor()
          By default returns the WebApplication's default request cycle processor.
 WebRequest getWebRequest()
          Casts Request to a WebRequest WARNING: Do not override this method.
 WebResponse getWebResponse()
          Casts Response to a WebResponse WARNING: Do not override this method.
 WebSession getWebSession()
          Casts Session to a WebSession WARNING: Do not override this method.
 boolean isRedirect()
          If it's an ajax request we always redirect.
protected  WebPage newBrowserInfoPage(String url)
          Override this method if you want to use a custom page for gathering the client's browser information.
The easiest way is just to extend BrowserInfoPage and provide your own markup file
protected  ClientInfo newClientInfo()
          Creates a new agent info object based on this request.
protected  void onExceptionLoop(RuntimeException e)
          Called when we catch a RuntimeException while already handling another
 void redirectTo(Page page)
          Redirects browser to the given page.
 
Methods inherited from class org.apache.wicket.RequestCycle
detach, get, getApplication, getClientInfo, getMetaData, getOriginalResponse, getPageParameters, getRedirect, getRequest, getRequestTarget, getResponse, getResponsePage, getResponsePageClass, getSession, getStartTime, isUrlForNewWindowEncoding, logRuntimeException, onAfterTargetsDetached, onBeginRequest, onEndRequest, onRequestTargetSet, onRuntimeException, request, request, request, set, setAutomaticallyClearFeedbackMessages, setMetaData, setRedirect, setRequest, setRequestTarget, setResponse, setResponsePage, setResponsePage, setResponsePage, setResponsePage, setUrlForNewWindowEncoding, toString, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, wasHandled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebRequestCycle

public WebRequestCycle(WebApplication application,
                       WebRequest request,
                       Response response)
Constructor which simply passes arguments to superclass for storage there. This instance will be set as the current one for this thread.

Parameters:
application - The application
request - The request
response - The response
Method Detail

getProcessor

public IRequestCycleProcessor getProcessor()
By default returns the WebApplication's default request cycle processor. Typically, you don't override this method but instead override WebApplication.newRequestCycleProcessor().

if you decide to override this method to provide a custom processor per request cycle, any mounts done via WebApplication will not work and and RequestCycle.onRuntimeException(Page, RuntimeException) is not called unless you deliberately put effort in it to make it work.

Specified by:
getProcessor in class RequestCycle
Returns:
the processor for delegated request cycle handling
See Also:
RequestCycle.getProcessor()

onExceptionLoop

protected void onExceptionLoop(RuntimeException e)
Description copied from class: RequestCycle
Called when we catch a RuntimeException while already handling another

Overrides:
onExceptionLoop in class RequestCycle

getWebRequest

public WebRequest getWebRequest()
Casts Request to a WebRequest WARNING: Do not override this method. Use RequestCycle.setRequest(Request) if request substitution is needed, or override RequestCycle.getRequest().

Returns:
Request as a WebRequest

getWebResponse

public WebResponse getWebResponse()
Casts Response to a WebResponse WARNING: Do not override this method. Use RequestCycle.setResponse(Response) if response substitution is needed, or override RequestCycle.getResponse().

Returns:
Response as a WebResponse

getWebSession

public WebSession getWebSession()
Casts Session to a WebSession WARNING: Do not override this method.

Returns:
Session as a WebSession

redirectTo

public final void redirectTo(Page page)
Redirects browser to the given page. NOTE: Usually, you should never call this method directly, but work with setResponsePage instead. This method is part of Wicket's internal behavior and should only be used when you want to circumvent the normal framework behavior and issue the redirect directly.

Specified by:
redirectTo in class RequestCycle
Parameters:
page - The page to redirect to

newClientInfo

protected ClientInfo newClientInfo()
Creates a new agent info object based on this request. Typically, this method is called once by the session and the returned object will be cached in the session after that call; we can expect the client to stay the same for the whole session, and implementations of RequestCycle.newClientInfo() might be relatively expensive.

To gather the client information this implementation redirects temporarily to a special page (BrowserInfoPage).

Note: Do not call this method from your custom Session constructor because the temporary page needs a constructed Session to be able to work.

If you need to set a default client info property then better use Session.setClientInfo(org.apache.wicket.request.ClientInfo) directly.

Specified by:
newClientInfo in class RequestCycle
Returns:
the agent info object based on this request

newBrowserInfoPage

protected WebPage newBrowserInfoPage(String url)
Override this method if you want to use a custom page for gathering the client's browser information.
The easiest way is just to extend BrowserInfoPage and provide your own markup file

Parameters:
url - the url to redirect to when the browser info is handled
Returns:
the WebPage which should be used while gathering browser info

isRedirect

public final boolean isRedirect()
If it's an ajax request we always redirect.

Overrides:
isRedirect in class RequestCycle
Returns:
whether the page for this request should be redirected
See Also:
RequestCycle.isRedirect()


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.