## org.codehaus.groovy.grails.web.servlet.view
Class GroovyPageView

    java.lang.Object
      org.springframework.context.support.ApplicationObjectSupport
          org.springframework.web.context.support.WebApplicationObjectSupport
              org.springframework.web.servlet.view.AbstractView
                  org.springframework.web.servlet.view.AbstractUrlBasedView
                      org.codehaus.groovy.grails.web.servlet.view.GroovyPageView

All Implemented Interfaces:
  BeanNameAware, InitializingBean, ApplicationContextAware, ServletContextAware, View

Direct Known Subclasses:
  ScaffoldedGroovyPageView

    public class GroovyPageView

extends AbstractUrlBasedView

A Spring View that renders Groovy Server Pages to the reponse. It requires an instance of GroovyPagesTemplateEngine to be set and will render to view returned by the getUrl() method of AbstractUrlBasedView This view also requires an instance of GrailsWebRequest to be bound to the currently executing Thread using Spring's RequestContextHolder. This can be done with by adding the GrailsWebRequestFilter.

Since:
  0.4

  Created: Feb 27, 2007 Time: 8:25:10 AM
Author:
  Graeme Rocher
See Also:
  `AbstractUrlBasedView.getUrl()`, `GroovyPagesTemplateEngine`, `GrailsWebRequestFilter`, `RequestContextHolder`

Field Summary
`static String` `EXCEPTION_MODEL_KEY`

Fields inherited from class org.springframework.web.servlet.view.AbstractView
`DEFAULT_CONTENT_TYPE`

Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
`logger`

Fields inherited from interface org.springframework.web.servlet.View
`RESPONSE_STATUS_ATTRIBUTE`

Constructor Summary
`GroovyPageView()`

Method Summary
`protected Writer` `createResponseWriter(HttpServletResponse response)` Creates the Response Writer for the specified HttpServletResponse instance
`protected void` `handleException(Exception exception, Writer out, GroovyPagesTemplateEngine engine, HttpServletRequest request, HttpServletResponse response)` Performs exception handling by attempting to render the Errors view
`protected void` `renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)` Delegates to renderMergedOutputModel(..)
`protected void` `renderWithTemplateEngine(GroovyPagesTemplateEngine templateEngine, Map model, HttpServletResponse response, HttpServletRequest request)` Renders a page with the specified TemplateEngine, mode and response
`void` `setTemplateEngine(GroovyPagesTemplateEngine templateEngine)`

Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
`afterPropertiesSet, checkResource, getUrl, isUrlRequired, setUrl, toString`

Methods inherited from class org.springframework.web.servlet.view.AbstractView
`addStaticAttribute, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute, writeToResponse`

Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
`getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext`

Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
`getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext`

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

Field Detail

### EXCEPTION_MODEL_KEY

    public static final String EXCEPTION_MODEL_KEY

See Also:
  Constant Field Values

Constructor Detail

### GroovyPageView

    public GroovyPageView()

Method Detail

### renderMergedOutputModel

    protected final void renderMergedOutputModel(Map model,
                                                 HttpServletRequest request,
                                                 HttpServletResponse response)
                                          throws Exception

  Delegates to renderMergedOutputModel(..)

  Specified by:
    `renderMergedOutputModel` in class `AbstractView`
  Parameters:
    `model` - The view model
    `request` - The HttpServletRequest
    `response` - The HttpServletResponse
  Throws:
    `Exception` - When an error occurs rendering the view
  See Also:
    `renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)`

### renderWithTemplateEngine

    protected void renderWithTemplateEngine(GroovyPagesTemplateEngine templateEngine,
                                            Map model,
                                            HttpServletResponse response,
                                            HttpServletRequest request)
                                     throws IOException

  Renders a page with the specified TemplateEngine, mode and response

  Parameters:
    `templateEngine` - The TemplateEngine to use
    `model` - The model to use
    `response` - The HttpServletResponse instance
    `request` - The HttpServletRequest
  Throws:
    `IOException` - Thrown when an error occurs writing the response

### handleException

    protected void handleException(Exception exception,
                                   Writer out,
                                   GroovyPagesTemplateEngine engine,
                                   HttpServletRequest request,
                                   HttpServletResponse response)

  Performs exception handling by attempting to render the Errors view

  Parameters:
    `exception` - The exception that occured
    `out` - The Writer
    `engine` - The GSP engine

### createResponseWriter

    protected Writer createResponseWriter(HttpServletResponse response)

  Creates the Response Writer for the specified HttpServletResponse instance

  Parameters:
    `response` - The HttpServletResponse instance
  Returns:
    A response Writer

### setTemplateEngine

    public void setTemplateEngine(GroovyPagesTemplateEngine templateEngine)

Copyright (c) 2005-2009 The Grails project