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

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

public class ServletWebRequest
extends WebRequest

WebRequest subclass that wraps a HttpServletRequest object.

Author:
Matej Knopp, Juergen Donnerstag, Igor Vaynberg

Field Summary
 
Fields inherited from class org.apache.wicket.request.http.WebRequest
HEADER_AJAX, HEADER_AJAX_BASE_URL, PARAM_AJAX, PARAM_AJAX_BASE_URL
 
Constructor Summary
ServletWebRequest(javax.servlet.http.HttpServletRequest httpServletRequest, java.lang.String filterPrefix)
          Construct.
ServletWebRequest(javax.servlet.http.HttpServletRequest httpServletRequest, java.lang.String filterPrefix, Url url)
          Construct.
 
Method Summary
 ServletWebRequest cloneWithUrl(Url url)
          Returns request with specified URL and same POST parameters as this request.
protected  java.util.Map<java.lang.String,java.util.List<StringValue>> generatePostParameters()
           
 java.nio.charset.Charset getCharset()
          Gets charset of the request
 Url getClientUrl()
          Returns base url without context or filter mapping.
 javax.servlet.http.HttpServletRequest getContainerRequest()
          Provides access to the low-level container request object that implementaion of this Request delegate to.
 java.lang.String getContextPath()
          Returns the context path or an empty string if the application is running under root context.
 java.util.List<javax.servlet.http.Cookie> getCookies()
           
 Time getDateHeader(java.lang.String name)
          Returns the value of the specified request header as a long value that represents a Date object.
 java.lang.String getFilterPath()
          Returns the path to which wicket Filter is mapped or an empty string if the filter is mapped to /*.
 java.lang.String getFilterPrefix()
          Returns the prefix of Wicket filter (without the leading /)
 java.lang.String getHeader(java.lang.String name)
          Returns the value of the specified request header as a String
 java.util.List<java.lang.String> getHeaders(java.lang.String name)
          Returns all the values of the specified request header.
 java.util.Locale getLocale()
          Returns locale for this request.
 IRequestParameters getPostParameters()
           
 java.lang.String getPrefixToContextPath()
          Returns prefix from Wicket Filter mapping to context path.
 Url getUrl()
          Returns the URL for this request.
 MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, java.lang.String upload)
          Creates multipart web request from this request.
 MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, java.lang.String upload, FileItemFactory factory)
          Creates multipart web request from this request.
 boolean shouldPreserveClientUrl()
          Signals whether or not request processing should preserve the current client url - in other words, handle this request without redirecting.
 
Methods inherited from class org.apache.wicket.request.http.WebRequest
getCookie, getIfModifiedSinceHeader, isAjax
 
Methods inherited from class org.apache.wicket.request.Request
getOriginalUrl, getQueryParameters, getRequestParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletWebRequest

public ServletWebRequest(javax.servlet.http.HttpServletRequest httpServletRequest,
                         java.lang.String filterPrefix)
Construct.

Parameters:
httpServletRequest -
filterPrefix - contentPath + filterPath, used to extract the actual Url

ServletWebRequest

public ServletWebRequest(javax.servlet.http.HttpServletRequest httpServletRequest,
                         java.lang.String filterPrefix,
                         Url url)
Construct.

Parameters:
httpServletRequest -
filterPrefix - contentPath + filterPath, used to extract the actual Url
url -
Method Detail

getClientUrl

public Url getClientUrl()
Returns base url without context or filter mapping. Example: if current url is
 http://localhost:8080/context/filter/mapping/wicket/bookmarkable/com.foo.Page?1&id=2
 
the base url is wicket/bookmarkable/com.foo.Page

Specified by:
getClientUrl in class Request
Returns:
client url
See Also:
Request.getClientUrl()

getFilterPrefix

public java.lang.String getFilterPrefix()
Returns the prefix of Wicket filter (without the leading /)

Returns:
Wicket filter prefix

getCookies

public java.util.List<javax.servlet.http.Cookie> getCookies()
Specified by:
getCookies in class WebRequest
Returns:
request cookies

getLocale

public java.util.Locale getLocale()
Description copied from class: Request
Returns locale for this request.

Specified by:
getLocale in class Request
Returns:
locale

getDateHeader

public Time getDateHeader(java.lang.String name)
Description copied from class: WebRequest
Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.

Specified by:
getDateHeader in class WebRequest
Returns:
date value of request header or null if not found

getHeader

public java.lang.String getHeader(java.lang.String name)
Description copied from class: WebRequest
Returns the value of the specified request header as a String

Specified by:
getHeader in class WebRequest
Returns:
string value of request header

getHeaders

public java.util.List<java.lang.String> getHeaders(java.lang.String name)
Description copied from class: WebRequest
Returns all the values of the specified request header.

Specified by:
getHeaders in class WebRequest
Returns:
unmodifiable list of header values

generatePostParameters

protected java.util.Map<java.lang.String,java.util.List<StringValue>> generatePostParameters()

getPostParameters

public IRequestParameters getPostParameters()
Overrides:
getPostParameters in class Request
Returns:
POST request parameters for this request.

getUrl

public Url getUrl()
Description copied from class: Request
Returns the URL for this request. URL is relative to Wicket filter path.

Specified by:
getUrl in class Request
Returns:
Url instance

cloneWithUrl

public ServletWebRequest cloneWithUrl(Url url)
Description copied from class: WebRequest
Returns request with specified URL and same POST parameters as this request.

Overrides:
cloneWithUrl in class WebRequest
Parameters:
url - Url instance
Returns:
request with specified URL.

newMultipartWebRequest

public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize,
                                                         java.lang.String upload)
                                                  throws FileUploadException
Creates multipart web request from this request.

Parameters:
maxSize -
upload - upload identifier for UploadInfo
Returns:
multipart request
Throws:
FileUploadException

newMultipartWebRequest

public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize,
                                                         java.lang.String upload,
                                                         FileItemFactory factory)
                                                  throws FileUploadException
Creates multipart web request from this request.

Parameters:
maxSize -
upload - upload identifier for UploadInfo
factory -
Returns:
multipart request
Throws:
FileUploadException

getPrefixToContextPath

public java.lang.String getPrefixToContextPath()
Description copied from class: Request
Returns prefix from Wicket Filter mapping to context path. This method does not take the actual URL into account.

For example if Wicket filter is mapped to hello/* this method should return ../ regardless of actual URL (after Wicket filter)

Overrides:
getPrefixToContextPath in class Request
Returns:
prefix to context path for this request.

getCharset

public java.nio.charset.Charset getCharset()
Description copied from class: Request
Gets charset of the request

Specified by:
getCharset in class Request
Returns:
request charset

getContainerRequest

public javax.servlet.http.HttpServletRequest getContainerRequest()
Description copied from class: Request
Provides access to the low-level container request object that implementaion of this Request delegate to. This allows users to access features provided by the container requests but not by generalized Wicket Request objects.

Specified by:
getContainerRequest in class Request
Returns:
low-level container request object, or null if none

getContextPath

public java.lang.String getContextPath()
Description copied from class: Request
Returns the context path or an empty string if the application is running under root context. Returned path, unless an empty string, will always start with a slash and will never end with a slash.

Overrides:
getContextPath in class Request
Returns:
context path

getFilterPath

public java.lang.String getFilterPath()
Description copied from class: Request
Returns the path to which wicket Filter is mapped or an empty string if the filter is mapped to /*. Returned path, unless an empty string, will always start with a slash and will never end with a slash.

Overrides:
getFilterPath in class Request
Returns:
filter path

shouldPreserveClientUrl

public boolean shouldPreserveClientUrl()
Description copied from class: WebRequest
Signals whether or not request processing should preserve the current client url - in other words, handle this request without redirecting. By default, this method returns false . For example, this method can be used to preserve the url that caused a 404 in the browser if Wicket is also responsible for rendering the 404 page. If this method returns the default value of false then Wicket will redirect to the bookmarkable url of the error page, instead of preserving the url that caused the 404 in the browser.

Overrides:
shouldPreserveClientUrl in class WebRequest
Returns:
true if current client url should be preserved


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