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

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.view.AbstractView
              extended by org.springframework.web.servlet.view.AbstractUrlBasedView
                  extended by 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
 
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)
          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
 
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
afterPropertiesSet, getUrl, isUrlRequired, setUrl, toString
 
Methods inherited from class org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createRequestContext, exposeModelAsRequestAttributes, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, 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)
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


Copyright (c) 2005-2006 The Grails project