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

java.lang.Object
  extended by org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper
All Implemented Interfaces:
GrailsControllerHelper

public class SimpleGrailsControllerHelper
extends Object
implements GrailsControllerHelper

This is a helper class that does the main job of dealing with Grails web requests

Since:
0.1 Created: 12-Jan-2006
Author:
Graeme Rocher

Constructor Summary
SimpleGrailsControllerHelper(GrailsApplication application, ApplicationContext context, ServletContext servletContext)
           
 
Method Summary
protected  ModelAndView executeAction(groovy.lang.GroovyObject controller, GrailsControllerClass controllerClass, String viewName, HttpServletRequest request, HttpServletResponse response, Map params)
          Invokes the action defined by the webRequest for the given arguments
 GrailsControllerClass getControllerClassByName(String name)
          Retrieves a controller class for the specified class name
 GrailsControllerClass getControllerClassByURI(String uri)
          Retrieves a GrailsControllerClass by URI
 groovy.lang.GroovyObject getControllerInstance(GrailsControllerClass controllerClass)
          Creates a new controller instance for the specified GrailsControllerClass
 GrailsApplicationAttributes getGrailsAttributes()
           
 ServletContext getServletContext()
           
 Object handleAction(groovy.lang.GroovyObject controller, groovy.lang.Closure action, HttpServletRequest request, HttpServletResponse response)
          Handles a Controller action
 Object handleAction(groovy.lang.GroovyObject controller, groovy.lang.Closure action, HttpServletRequest request, HttpServletResponse response, Map params)
          Handles a Controller action
 ModelAndView handleActionResponse(groovy.lang.GroovyObject controller, Object returnValue, String closurePropertyName, String viewName)
          Processes an action response for the specified arguments
 ModelAndView handleURI(String uri, GrailsWebRequest webRequest)
          Handles a Grails URI
 ModelAndView handleURI(String uri, GrailsWebRequest webRequest, Map params)
          Handles a Grails URI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleGrailsControllerHelper

public SimpleGrailsControllerHelper(GrailsApplication application,
                                    ApplicationContext context,
                                    ServletContext servletContext)
Method Detail

getServletContext

public ServletContext getServletContext()
Specified by:
getServletContext in interface GrailsControllerHelper
Returns:
The servlet context instance

getControllerClassByName

public GrailsControllerClass getControllerClassByName(String name)
Description copied from interface: GrailsControllerHelper
Retrieves a controller class for the specified class name

Specified by:
getControllerClassByName in interface GrailsControllerHelper
Returns:
The controller class or null

getControllerClassByURI

public GrailsControllerClass getControllerClassByURI(String uri)
Description copied from interface: GrailsControllerHelper
Retrieves a GrailsControllerClass by URI

Specified by:
getControllerClassByURI in interface GrailsControllerHelper
Parameters:
uri - The URI to lookup
Returns:
A GrailsControllerClass

getControllerInstance

public groovy.lang.GroovyObject getControllerInstance(GrailsControllerClass controllerClass)
Description copied from interface: GrailsControllerHelper
Creates a new controller instance for the specified GrailsControllerClass

Specified by:
getControllerInstance in interface GrailsControllerHelper
Parameters:
controllerClass - The GrailsControllerClass
Returns:
A new controller instance

handleURI

public ModelAndView handleURI(String uri,
                              GrailsWebRequest webRequest)
Description copied from interface: GrailsControllerHelper
Handles a Grails URI

Specified by:
handleURI in interface GrailsControllerHelper
Parameters:
uri - The URI to processs
webRequest - The GrailsWebRequest
Returns:
A ModelAndView instance

handleURI

public ModelAndView handleURI(String uri,
                              GrailsWebRequest webRequest,
                              Map params)
Description copied from interface: GrailsControllerHelper
Handles a Grails URI

Specified by:
handleURI in interface GrailsControllerHelper
Parameters:
uri - The URI to processs
webRequest - the GrailsWebRequest instance
params - A map of controller parameters
Returns:
A ModelAndView instance

executeAction

protected ModelAndView executeAction(groovy.lang.GroovyObject controller,
                                     GrailsControllerClass controllerClass,
                                     String viewName,
                                     HttpServletRequest request,
                                     HttpServletResponse response,
                                     Map params)
Invokes the action defined by the webRequest for the given arguments

Parameters:
controller - The controller instance
controllerClass - The GrailsControllerClass that defines the conventions within the controller
viewName - The name of the view to delegate to if necessary
request - The HttpServletRequest object
response - The HttpServletResponse object
params - A map of parameters
Returns:
A Spring ModelAndView instance

getGrailsAttributes

public GrailsApplicationAttributes getGrailsAttributes()
Specified by:
getGrailsAttributes in interface GrailsControllerHelper
Returns:
Returns the grails request attributes instance

handleAction

public Object handleAction(groovy.lang.GroovyObject controller,
                           groovy.lang.Closure action,
                           HttpServletRequest request,
                           HttpServletResponse response)
Description copied from interface: GrailsControllerHelper
Handles a Controller action

Specified by:
handleAction in interface GrailsControllerHelper
action - An action Closure instance
request - The request object
response - The response
Returns:
The action response

handleAction

public Object handleAction(groovy.lang.GroovyObject controller,
                           groovy.lang.Closure action,
                           HttpServletRequest request,
                           HttpServletResponse response,
                           Map params)
Description copied from interface: GrailsControllerHelper
Handles a Controller action

Specified by:
handleAction in interface GrailsControllerHelper
action - An action Closure instance
request - The request object
response - The response
params - A Map of controller parameters
Returns:
The action response

handleActionResponse

public ModelAndView handleActionResponse(groovy.lang.GroovyObject controller,
                                         Object returnValue,
                                         String closurePropertyName,
                                         String viewName)
Description copied from interface: GrailsControllerHelper
Processes an action response for the specified arguments

Specified by:
handleActionResponse in interface GrailsControllerHelper
Parameters:
controller - The controller instance
returnValue - The response from the closure
closurePropertyName - The property name of the closure
viewName - The name of the view
Returns:
A ModelAndView object


Copyright (c) 2005-2009 The Grails project