org.loom.servlet
Interface LoomServletRequest

All Superinterfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest
All Known Implementing Classes:
LoomServletRequestImpl

public interface LoomServletRequest
extends javax.servlet.http.HttpServletRequest

An enhanced implementation of the HttpServletRequest interface


Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Method Summary
 void addFileParameter(java.lang.String name, FileParameter item)
          Add an uploaded file parameter
 void addStringParameter(java.lang.String name, java.lang.String value)
          Add a String parameter
 UrlBuilder createUrl()
          Creates a new empty UrlBuilder
 UrlBuilder createUrl(java.lang.Class<? extends Action> actionClass, java.lang.String event)
          Creates a new UrlBuilder pointing to the provided action and event
 UrlBuilder createUrl(java.lang.String url)
          Creates a new UrlBuilder pointing to the provided raw url
 java.lang.String generateId(java.lang.String prefix)
          Generates a valid HTML id starting with prefix.
 java.lang.String generateIndex(java.lang.String name)
          Generate a correlative index for the field passed as argument, in the form: field[0], field[1], etc.
 ActionMappingRepository getActionMappingRepository()
           
 boolean getAttributeAsBoolean(java.lang.String attributeName)
           
 BrowserData getBrowserData()
           
 javax.servlet.http.Cookie getCookie(java.lang.String cookieName)
           
 FormTag getCurrentForm()
          TODO: this method should be moved elsewhere
 FileParameter getFileParameter(java.lang.String name)
           
 HttpMethod getHttpMethod()
           
 MessagesRepository getMessagesRepository()
           
 FlashContext getNextFlashContext(boolean create)
          Return the flash-scoped context with objects persisted for the NEXT browser request.
 ParsedAction getParsedAction()
           
 FlashContext getPreviousFlashContext()
          Return the flash-scoped context with objects persisted from the PREVIOUS browser request.
 ServletRequestParameters getRequestParameters()
           
 java.lang.String getRequestUrlWithParameters()
          Deprecated. use toUrlBuilder().getURL() instead
 java.lang.Object getScopedAttribute(java.lang.String name, Scope... scopes)
          Get a scoped attribute
 java.lang.String getStringParameter(java.lang.String name)
           
 boolean isAjax()
          Return true if the current request has been launched using Ajax.
 void removeScopedAttribute(java.lang.String name, Scope scope)
          Remove a scoped atribute
 void setCurrentForm(FormTag currentForm)
           
 void setScopedAttribute(java.lang.String name, java.lang.Object value, Scope scope)
          Create a scoped atribute
 UrlBuilder toUrlBuilder()
          Create a UrlBuilder instance with the same action/event/rawUrl and all the parameters included in this request instance.
 
Methods inherited from interface javax.servlet.http.HttpServletRequest
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Method Detail

getMessagesRepository

MessagesRepository getMessagesRepository()
Returns:
the MessagesRepository corresponding to the this request

getParsedAction

ParsedAction getParsedAction()
Returns:
the action that is handling this request, null if none

getCurrentForm

FormTag getCurrentForm()
TODO: this method should be moved elsewhere

Returns:
the current JSP form tag, null if none.

setCurrentForm

void setCurrentForm(FormTag currentForm)

generateId

java.lang.String generateId(java.lang.String prefix)
Generates a valid HTML id starting with prefix.

Parameters:
prefix - the prefix to use to generate the id
Returns:
A generated correlative id starting at 0: prefix_0, prefix_1, etc.

generateIndex

java.lang.String generateIndex(java.lang.String name)
Generate a correlative index for the field passed as argument, in the form: field[0], field[1], etc. To generate HTML ID for an entire web page, see generateId

Returns:
the generated field name, e.g.: "field[0]"

addFileParameter

void addFileParameter(java.lang.String name,
                      FileParameter item)
Add an uploaded file parameter

Parameters:
name - the file parameter name
item - the uploaded file to add to this request

addStringParameter

void addStringParameter(java.lang.String name,
                        java.lang.String value)
Add a String parameter

Parameters:
name - the name of the parameter
value - the value of the parameter

getRequestParameters

ServletRequestParameters getRequestParameters()
Returns:
a ServletRequestParameters instance with all file upload parameters and plain parameters in a single map.

getStringParameter

java.lang.String getStringParameter(java.lang.String name)
Returns:
the GET/POST parameter value

getFileParameter

FileParameter getFileParameter(java.lang.String name)
Returns:
the uploaded file

getCookie

javax.servlet.http.Cookie getCookie(java.lang.String cookieName)
Parameters:
cookieName - the name of the cookie
Returns:
the cookie value, null if none

getRequestUrlWithParameters

java.lang.String getRequestUrlWithParameters()
Deprecated. use toUrlBuilder().getURL() instead

Returns the full url including query parameters, protocol, server and port. This will convert a POST request into a GET one, if there are no uploaded files.

Throws:
java.lang.RuntimeException - if the request include any uploaded files.

isAjax

boolean isAjax()
Return true if the current request has been launched using Ajax. Actually, it looks for a 'X-Requested-With' HTTP header, that is added by JQuery and prototype.

Returns:
true if the request has been launched using XmlHttpRequest, false if this is a normal request.

getAttributeAsBoolean

boolean getAttributeAsBoolean(java.lang.String attributeName)
Returns:
a request attribute, as a boolean. If null, returns false.

getBrowserData

BrowserData getBrowserData()
Returns:
the data that can be sniffed from the browser.

setScopedAttribute

void setScopedAttribute(java.lang.String name,
                        java.lang.Object value,
                        Scope scope)
Create a scoped atribute

Parameters:
name - the attribute name
value - the value
scope - the scope of the attribute. Scope.PAGE is not allowed.

getScopedAttribute

java.lang.Object getScopedAttribute(java.lang.String name,
                                    Scope... scopes)
Get a scoped attribute

Parameters:
name - the attribute name
scopes - the list of scopes to inspect, null for all. Scope.PAGE is not allowed.

removeScopedAttribute

void removeScopedAttribute(java.lang.String name,
                           Scope scope)
Remove a scoped atribute

Parameters:
name - the attribute name
scope - the scope of the attribute. Scope.PAGE is not allowed.

getHttpMethod

HttpMethod getHttpMethod()
Returns:
the HttpMethod of this request. Note that the method used by the browser could be overriden if this is a POST request and the _method parameter is present.

toUrlBuilder

UrlBuilder toUrlBuilder()
Create a UrlBuilder instance with the same action/event/rawUrl and all the parameters included in this request instance. Any file parameters will be lost.

Returns:
the craeted UrlBuilder instance.

createUrl

UrlBuilder createUrl()
Creates a new empty UrlBuilder


createUrl

UrlBuilder createUrl(java.lang.Class<? extends Action> actionClass,
                     java.lang.String event)
Creates a new UrlBuilder pointing to the provided action and event


createUrl

UrlBuilder createUrl(java.lang.String url)
Creates a new UrlBuilder pointing to the provided raw url


getNextFlashContext

FlashContext getNextFlashContext(boolean create)
Return the flash-scoped context with objects persisted for the NEXT browser request.

Parameters:
create - if true, create the flash context if it does not yet exist.

getPreviousFlashContext

FlashContext getPreviousFlashContext()
Return the flash-scoped context with objects persisted from the PREVIOUS browser request.


getActionMappingRepository

ActionMappingRepository getActionMappingRepository()