## org.codehaus.groovy.grails.scaffolding
Class TemplateGeneratingResponseHandler

    java.lang.Object
      org.codehaus.groovy.grails.scaffolding.TemplateGeneratingResponseHandler

All Implemented Interfaces:
  ScaffoldResponseHandler, ApplicationContextAware

    public class TemplateGeneratingResponseHandler

extends Object
implements ScaffoldResponseHandler, ApplicationContextAware

A response handler that uses a GroovyPageTemplateEngine instance to write Templates directly to the response. Also requires a reference to the ViewResolver to establish whether a view already exists for the response, in which case it delegates to the view.

Since:
  0.5

  Created: Feb 27, 2007 Time: 7:45:46 AM
Author:
  Graeme Rocher
See Also:
  `ViewResolver`, `GrailsViewResolver`, `GroovyPagesTemplateEngine`

Constructor Summary
`TemplateGeneratingResponseHandler()`

Method Summary
`void` `clearViewCache()` Clears the cache of generated views.
`protected ModelAndView` `createScaffoldedResponse(String uri, Map model, String actionName)` Takes the given URI and model and either retrieves a cached view or generates and places the generated view into a ScaffoldedGroovyPageView instance
`ModelAndView` `handleResponse(HttpServletRequest request, HttpServletResponse response, String actionName, Map model)` Either delegates to a pre-existing view or renders an in-memory scaffolded view to the response
`void` `setApplicationContext(ApplicationContext applicationContext)`
`void` `setGrailsApplication(GrailsApplication grailsApplication)`
`void` `setScaffoldedClass(Class scaffoldedClass)`
`void` `setTemplateGenerator(GrailsTemplateGenerator templateGenerator)` Sets the Scaffolding GrailsTemplateGenerator to use when generating templates
`void` `setViewResolver(ViewResolver resolver)` Sets the ViewResolver this ResponseHandler should use to resolve pre-existing views

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TemplateGeneratingResponseHandler

    public TemplateGeneratingResponseHandler()

Method Detail

### clearViewCache

    public void clearViewCache()

  Clears the cache of generated views. Scaffolded views will subsequently be re-generated

### handleResponse

    public ModelAndView handleResponse(HttpServletRequest request,
                                       HttpServletResponse response,
                                       String actionName,
                                       Map model)

  Either delegates to a pre-existing view or renders an in-memory scaffolded view to the response

  Specified by:
    `handleResponse` in interface `ScaffoldResponseHandler`
  Parameters:
    `request` - The HttpServletRequest
    `response` - The HttpServletResponse
    `actionName` - The name of the action to handle
    `model` - The View model
  Returns:
    A Spring ModelAndView instance

### createScaffoldedResponse

    protected ModelAndView createScaffoldedResponse(String uri,
                                                    Map model,
                                                    String actionName)

  Takes the given URI and model and either retrieves a cached view or generates and places the generated view into a ScaffoldedGroovyPageView instance

  Parameters:
    `uri` - The URI of the view
    `model` - The model of the view
    `actionName` -
  Returns:
    A Spring ModelAndView instance

### setViewResolver

    public void setViewResolver(ViewResolver resolver)

  Sets the ViewResolver this ResponseHandler should use to resolve pre-existing views

  Specified by:
    `setViewResolver` in interface `ScaffoldResponseHandler`
  Parameters:
    `resolver` - The ViewResolver

### setTemplateGenerator

    public void setTemplateGenerator(GrailsTemplateGenerator templateGenerator)

  Sets the Scaffolding GrailsTemplateGenerator to use when generating templates

  Parameters:
    `templateGenerator` - The GrailsTemplateGenerator instance

### setScaffoldedClass

    public void setScaffoldedClass(Class scaffoldedClass)

### setGrailsApplication

    public void setGrailsApplication(GrailsApplication grailsApplication)

### setApplicationContext

    public void setApplicationContext(ApplicationContext applicationContext)
                               throws BeansException

  Specified by:
    `setApplicationContext` in interface `ApplicationContextAware`
  Throws:
    `BeansException`

Copyright (c) 2005-2006 The Grails project