org.codehaus.groovy.grails.web.servlet.mvc
Class GrailsWebRequest

java.lang.Object
  extended by org.springframework.web.context.request.AbstractRequestAttributes
      extended by org.springframework.web.context.request.ServletRequestAttributes
          extended by org.springframework.web.context.request.ServletWebRequest
              extended by org.springframework.web.servlet.handler.DispatcherServletWebRequest
                  extended by org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
All Implemented Interfaces:
ParameterInitializationCallback, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.context.request.RequestAttributes, org.springframework.web.context.request.WebRequest

public class GrailsWebRequest
extends org.springframework.web.servlet.handler.DispatcherServletWebRequest
implements ParameterInitializationCallback

Encapsulates a Grails request. An instance of this class is bound to the current thread using Spring's RequestContextHolder which can later be retrieved using: def webRequest = RequestContextHolder.currentRequestAttributes()

Since:
0.4

Field Summary
static java.lang.String ID_PARAMETER
           
 
Fields inherited from class org.springframework.web.context.request.ServletRequestAttributes
DESTRUCTION_CALLBACK_NAME_PREFIX
 
Fields inherited from class org.springframework.web.context.request.AbstractRequestAttributes
requestDestructionCallbacks
 
Fields inherited from interface org.springframework.web.context.request.RequestAttributes
REFERENCE_REQUEST, REFERENCE_SESSION, SCOPE_GLOBAL_SESSION, SCOPE_REQUEST, SCOPE_SESSION
 
Constructor Summary
GrailsWebRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext)
           
GrailsWebRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext, org.springframework.context.ApplicationContext applicationContext)
           
 
Method Summary
 void addParameterListener(ParameterCreationListener creationListener)
          Adds a listener that will be called when the parameters are created.
 java.lang.String getActionName()
           
 org.springframework.context.ApplicationContext getApplicationContext()
          Obtains the ApplicationContext object.
 GrailsApplicationAttributes getAttributes()
           
 java.lang.String getBaseUrl()
           
 java.lang.String getContextPath()
          Returns the context path of the request.
 java.lang.String getControllerName()
           
 javax.servlet.http.HttpServletRequest getCurrentRequest()
           
 javax.servlet.http.HttpServletResponse getCurrentResponse()
           
 FlashScope getFlashScope()
           
 java.lang.String getId()
           
 java.io.Writer getOut()
           
 java.util.Map getParameterMap()
          Overriden to return the GrailsParameterMap instance,
 GrailsParameterMap getParams()
           
 org.springframework.beans.PropertyEditorRegistry getPropertyEditorRegistry()
          Obtains the PropertyEditorRegistry instance.
 javax.servlet.ServletContext getServletContext()
           
 GrailsHttpSession getSession()
           
 void informParameterCreationListeners()
          Informs any parameter creation listeners.
 boolean isActive()
          Whether the web request is still active
 boolean isFlowRequest()
          Returns true if the current executing request is a flow request
 boolean isRenderView()
           
static GrailsWebRequest lookup()
          Looks up the current Grails WebRequest instance
static GrailsWebRequest lookup(javax.servlet.http.HttpServletRequest request)
          Looks up the GrailsWebRequest from the current request.
static org.codehaus.groovy.grails.commons.GrailsApplication lookupApplication()
          Looks up the GrailsApplication from the current request.
 void requestCompleted()
           
 void setActionName(java.lang.String actionName)
           
 void setControllerName(java.lang.String controllerName)
           
 void setId(java.lang.Object id)
          Sets the id of the request.
 void setOut(java.io.Writer out)
           
 void setRenderView(boolean renderView)
           
 
Methods inherited from class org.springframework.web.servlet.handler.DispatcherServletWebRequest
getLocale
 
Methods inherited from class org.springframework.web.context.request.ServletWebRequest
checkNotModified, checkNotModified, getDescription, getHeader, getHeaderNames, getHeaderValues, getNativeRequest, getNativeRequest, getNativeResponse, getNativeResponse, getParameter, getParameterNames, getParameterValues, getRemoteUser, getResponse, getUserPrincipal, isNotModified, isSecure, isUserInRole, toString
 
Methods inherited from class org.springframework.web.context.request.ServletRequestAttributes
getAttribute, getAttributeNames, getRequest, getSession, getSessionId, getSessionMutex, registerDestructionCallback, registerSessionDestructionCallback, removeAttribute, resolveReference, setAttribute, updateAccessedSessionAttributes
 
Methods inherited from class org.springframework.web.context.request.AbstractRequestAttributes
isRequestActive, registerRequestDestructionCallback, removeRequestDestructionCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.web.context.request.RequestAttributes
getAttribute, getAttributeNames, getSessionId, getSessionMutex, registerDestructionCallback, removeAttribute, resolveReference, setAttribute
 

Field Detail

ID_PARAMETER

public static final java.lang.String ID_PARAMETER
See Also:
Constant Field Values
Constructor Detail

GrailsWebRequest

public GrailsWebRequest(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        javax.servlet.ServletContext servletContext)

GrailsWebRequest

public GrailsWebRequest(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        javax.servlet.ServletContext servletContext,
                        org.springframework.context.ApplicationContext applicationContext)
Method Detail

getParameterMap

public java.util.Map getParameterMap()
Overriden to return the GrailsParameterMap instance,

Specified by:
getParameterMap in interface org.springframework.web.context.request.WebRequest
Overrides:
getParameterMap in class org.springframework.web.context.request.ServletWebRequest
Returns:
An instance of GrailsParameterMap

requestCompleted

public void requestCompleted()
Overrides:
requestCompleted in class org.springframework.web.context.request.AbstractRequestAttributes

getOut

public java.io.Writer getOut()
Returns:
the out

isActive

public boolean isActive()
Whether the web request is still active

Returns:
true if it is

setOut

public void setOut(java.io.Writer out)
Parameters:
out - the out to set

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns:
The ServletContext instance

getContextPath

public java.lang.String getContextPath()
Returns the context path of the request.

Specified by:
getContextPath in interface org.springframework.web.context.request.WebRequest
Overrides:
getContextPath in class org.springframework.web.context.request.ServletWebRequest
Returns:
the path

getFlashScope

public FlashScope getFlashScope()
Returns:
The FlashScope instance for the current request

getCurrentRequest

public javax.servlet.http.HttpServletRequest getCurrentRequest()
Returns:
The currently executing request

getCurrentResponse

public javax.servlet.http.HttpServletResponse getCurrentResponse()

getParams

public GrailsParameterMap getParams()
Returns:
The Grails params object

informParameterCreationListeners

public void informParameterCreationListeners()
Informs any parameter creation listeners.


getSession

public GrailsHttpSession getSession()
Returns:
The Grails session object

getAttributes

public GrailsApplicationAttributes getAttributes()
Returns:
The GrailsApplicationAttributes instance

setActionName

public void setActionName(java.lang.String actionName)

setControllerName

public void setControllerName(java.lang.String controllerName)

getActionName

public java.lang.String getActionName()
Returns:
the actionName

getControllerName

public java.lang.String getControllerName()
Returns:
the controllerName

setRenderView

public void setRenderView(boolean renderView)

isRenderView

public boolean isRenderView()
Returns:
true if the view for this GrailsWebRequest should be rendered

getId

public java.lang.String getId()

isFlowRequest

public boolean isFlowRequest()
Returns true if the current executing request is a flow request

Returns:
true if it is a flow request

addParameterListener

public void addParameterListener(ParameterCreationListener creationListener)
Description copied from interface: ParameterInitializationCallback
Adds a listener that will be called when the parameters are created.

Specified by:
addParameterListener in interface ParameterInitializationCallback
Parameters:
creationListener - the listener

getApplicationContext

public org.springframework.context.ApplicationContext getApplicationContext()
Obtains the ApplicationContext object.

Returns:
The ApplicationContext

getPropertyEditorRegistry

public org.springframework.beans.PropertyEditorRegistry getPropertyEditorRegistry()
Obtains the PropertyEditorRegistry instance.

Returns:
The PropertyEditorRegistry

lookup

public static GrailsWebRequest lookup(javax.servlet.http.HttpServletRequest request)
Looks up the GrailsWebRequest from the current request.

Parameters:
request - The current request
Returns:
The GrailsWebRequest

lookup

public static GrailsWebRequest lookup()
Looks up the current Grails WebRequest instance

Returns:
The GrailsWebRequest instance

lookupApplication

public static org.codehaus.groovy.grails.commons.GrailsApplication lookupApplication()
Looks up the GrailsApplication from the current request.

Returns:
The GrailsWebRequest

setId

public void setId(java.lang.Object id)
Sets the id of the request.

Parameters:
id - The id

getBaseUrl

public java.lang.String getBaseUrl()