org.apache.wicket.protocol.http.servlet
Class ServletWebRequest

java.lang.Object
  extended by org.apache.wicket.Request
      extended by org.apache.wicket.protocol.http.WebRequest
          extended by org.apache.wicket.protocol.http.servlet.ServletWebRequest
Direct Known Subclasses:
MultipartServletWebRequest, UploadWebRequest

public class ServletWebRequest
extends WebRequest

A Servlet specific WebRequest implementation wrapping a HttpServletRequest

Author:
Ate Douma

Constructor Summary
ServletWebRequest(javax.servlet.http.HttpServletRequest httpServletRequest)
          Protected constructor.
 
Method Summary
 int getDepthRelativeToWicketHandler()
          Gets the depth of this request relative to the Wicket handler.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
          Gets the wrapped http servlet request object.
 Locale getLocale()
          Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
 String getParameter(String key)
          Gets the request parameter with the given key.
 Map getParameterMap()
          Gets the request parameters.
 String[] getParameters(String key)
          Gets the request parameters with the given key.
 String getPath()
          Gets the path info if any.
 String getQueryString()
          Returns the query string (part after ?) of this request.
 String getRelativePathPrefixToContextRoot()
          Gets a prefix to make this relative to the context root.
 String getRelativePathPrefixToWicketHandler()
          Gets a prefix to make this relative to the Wicket Servlet/Filter.
 String getServletPath()
          Gets the servlet path.
 String getURL()
          Retrieves the relative URL of this request for local use.
 boolean isAjax()
          This will return true if the header "Wicket-Ajax" is set.
 boolean mergeVersion()
          This method by default calls isAjax(), wicket ajax request do have an header set.
 WebRequest newMultipartWebRequest(Bytes maxsize)
          Create a runtime context type specific (e.g.
 void setAjax(boolean ajax)
          THIS IS FOR WICKET INTERNAL USE ONLY.
 void setForceNewVersion(boolean forceNewVersion)
          Allows to create new versions even on AJAX request.
 void setWicketRedirectUrl(String wicketRedirectUrl)
          Set the redirect url where wicket will redirect to for the next page
 String toString()
           
 
Methods inherited from class org.apache.wicket.protocol.http.WebRequest
getCookie, getCookies
 
Methods inherited from class org.apache.wicket.Request
decodeURL, getPage, getRelativeURL, getRequestParameters, setPage, setRequestParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServletWebRequest

public ServletWebRequest(javax.servlet.http.HttpServletRequest httpServletRequest)
Protected constructor.

Parameters:
httpServletRequest - The servlet request information
Method Detail

getHttpServletRequest

public final javax.servlet.http.HttpServletRequest getHttpServletRequest()
Gets the wrapped http servlet request object.

Specified by:
getHttpServletRequest in class WebRequest
Returns:
the wrapped http serlvet request object.

getLocale

public Locale getLocale()
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server.

Specified by:
getLocale in class WebRequest
Returns:
the preferred Locale for the client

getParameter

public String getParameter(String key)
Gets the request parameter with the given key.

Specified by:
getParameter in class WebRequest
Parameters:
key - Parameter name
Returns:
Parameter value

getParameterMap

public Map getParameterMap()
Gets the request parameters.

Specified by:
getParameterMap in class WebRequest
Returns:
Map of parameters

getParameters

public String[] getParameters(String key)
Gets the request parameters with the given key.

Specified by:
getParameters in class WebRequest
Parameters:
key - Parameter name
Returns:
Parameter values

getPath

public String getPath()
Gets the path info if any.

Specified by:
getPath in class Request
Returns:
Any servlet path info

getRelativePathPrefixToContextRoot

public String getRelativePathPrefixToContextRoot()
Description copied from class: Request
Gets a prefix to make this relative to the context root.

For example, if your context root is http://server.com/myApp/ and the request is for /myApp/mountedPage/, then the prefix returned might be "../../".

For a particular technology, this might return either an absolute prefix or a relative one.

Specified by:
getRelativePathPrefixToContextRoot in class Request
Returns:
Prefix relative to this request required to back up to context root.
See Also:
Request.getRelativePathPrefixToContextRoot()

getDepthRelativeToWicketHandler

public int getDepthRelativeToWicketHandler()
Gets the depth of this request relative to the Wicket handler.

Returns:
the depth

getRelativePathPrefixToWicketHandler

public String getRelativePathPrefixToWicketHandler()
Description copied from class: Request
Gets a prefix to make this relative to the Wicket Servlet/Filter.

For example, if your context root is http://server.com/myApp/ and the request is for /myApp/mountedPage/, then the prefix returned might be "../".

For a particular technology, this might return either an absolute prefix or a relative one.

Specified by:
getRelativePathPrefixToWicketHandler in class Request
Returns:
Prefix relative to this request required to back up to context root.
See Also:
Request.getRelativePathPrefixToWicketHandler()

getURL

public String getURL()
Description copied from class: Request
Retrieves the relative URL of this request for local use. This is relative to the context root.

Specified by:
getURL in class Request
Returns:
The relative request URL for local use
See Also:
Request.getURL()

getServletPath

public String getServletPath()
Gets the servlet path.

Specified by:
getServletPath in class WebRequest
Returns:
Servlet path

isAjax

public final boolean isAjax()
This will return true if the header "Wicket-Ajax" is set.

Specified by:
isAjax in class WebRequest
Returns:
True if the ajax is an ajax request. False if it's not.
See Also:
WebRequest.isAjax()

setAjax

public final void setAjax(boolean ajax)
THIS IS FOR WICKET INTERNAL USE ONLY. DO NOT USE IT IN YOUR APPLICATION.

Parameters:
ajax - ajax

mergeVersion

public boolean mergeVersion()
This method by default calls isAjax(), wicket ajax request do have an header set. And for all the ajax request the versioning should be merged with the previous one. And when it sees that the current request is a redirect to page request the version will also be merged with the previous one because refresh in the browser or redirects to a page shouldn't generate a new version.

Overrides:
mergeVersion in class Request
Returns:
true if the version must be merged with the previous latest.
See Also:
Request.mergeVersion()

setForceNewVersion

public void setForceNewVersion(boolean forceNewVersion)
Allows to create new versions even on AJAX request. This can come handly when the AJAX response does a real redirect.

Parameters:
forceNewVersion -

newMultipartWebRequest

public WebRequest newMultipartWebRequest(Bytes maxsize)
Description copied from class: WebRequest
Create a runtime context type specific (e.g. Servlet or Portlet) MultipartWebRequest wrapper for handling multipart content uploads.

Specified by:
newMultipartWebRequest in class WebRequest
Parameters:
maxsize - the maximum size this request may be
Returns:
new WebRequest wrapper implementing MultipartWebRequest
See Also:
WebRequest.newMultipartWebRequest(org.apache.wicket.util.lang.Bytes)

setWicketRedirectUrl

public void setWicketRedirectUrl(String wicketRedirectUrl)
Set the redirect url where wicket will redirect to for the next page

Parameters:
wicketRedirectUrl -

getQueryString

public String getQueryString()
Description copied from class: Request
Returns the query string (part after ?) of this request.

Specified by:
getQueryString in class Request
Returns:
request query string
See Also:
Request.getQueryString()

toString

public String toString()
Overrides:
toString in class Request
See Also:
Object.toString()


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