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

    java.lang.Object
      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 org.springframework.webflow.executor.support.FlowRequestHandler` `createRequestHandler(org.springframework.webflow.executor.support.FlowExecutorArgumentHandler argumentHandler)` Factory method that creates a new helper for processing a request into this flow controller.
`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
`protected ModelAndView` `executeFlow(GrailsWebRequest webRequest, HttpServletRequest request, HttpServletResponse response)` This method is responsible for execution of a flow based on the currently executing GrailsWebRequest
`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
`protected org.springframework.webflow.executor.FlowExecutor` `getFlowExecutor()` Retrieves the FlowExecutor instance stored in the ApplicationContext
`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
`protected ModelAndView` `toModelAndView(org.springframework.webflow.executor.ResponseInstruction responseInstruction, org.springframework.webflow.context.servlet.ServletExternalContext context, org.springframework.webflow.executor.support.FlowExecutorArgumentHandler argumentHandler)` Deals with translating a WebFlow ResponseInstruction instance into an appropriate Spring ModelAndView

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

### executeFlow

    protected ModelAndView executeFlow(GrailsWebRequest webRequest,
                                       HttpServletRequest request,
                                       HttpServletResponse response)

  This method is responsible for execution of a flow based on the currently executing GrailsWebRequest

  Parameters:
    `webRequest` - The GrailsWebRequest
    `request` - The HttpServletRequest instance
    `response` - The HttpServletResponse instance
  Returns:
    A Spring ModelAndView

### toModelAndView

    protected ModelAndView toModelAndView(org.springframework.webflow.executor.ResponseInstruction responseInstruction,
                                          org.springframework.webflow.context.servlet.ServletExternalContext context,
                                          org.springframework.webflow.executor.support.FlowExecutorArgumentHandler argumentHandler)

  Deals with translating a WebFlow ResponseInstruction instance into an appropriate Spring ModelAndView

  Parameters:
    `responseInstruction` - The ResponseInstruction instance
    `context` - The ExternalContext for the webflow
    `argumentHandler` - The FlowExecutorArgumentHandler instance
  Returns:
    A Spring ModelAndView instance

### createRequestHandler

    protected org.springframework.webflow.executor.support.FlowRequestHandler createRequestHandler(org.springframework.webflow.executor.support.FlowExecutorArgumentHandler argumentHandler)

  Factory method that creates a new helper for processing a request into this flow controller. The handler is a basic template encapsulating reusable flow execution request handling workflow. This implementation just creates a new `FlowRequestHandler`.

  Parameters:
    `argumentHandler` - The FlowExecutorArgumentHandler to use
  Returns:
    the controller helper

### 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

### getFlowExecutor

    protected org.springframework.webflow.executor.FlowExecutor getFlowExecutor()

  Retrieves the FlowExecutor instance stored in the ApplicationContext

  Returns:
    The FlowExecution

Copyright (c) 2005-2006 The Grails project