Groovy Documentation

## org.codehaus.groovy.grails.web.servlet.view
[Java] Class GroovyPageView

    java.lang.Object
      org.springframework.web.servlet.view.AbstractUrlBasedView
          org.codehaus.groovy.grails.web.servlet.view.GroovyPageView

    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.

Authors:
  Graeme Rocher

See Also:
  getUrl()
  GroovyPagesTemplateEngine
  GrailsWebRequestFilter
  org.springframework.web.context.request.RequestContextHolder

Since:
  0.4

Field Summary
`static java.lang.String` | `EXCEPTION_MODEL_KEY`

Method Summary
`protected java.io.Writer` | `createResponseWriter(HttpServletResponse response)` Creates the Response Writer for the specified HttpServletResponse instance.
`protected void` | `handleException(java.lang.Exception exception, java.io.Writer out, GroovyPagesTemplateEngine engine, HttpServletRequest request, HttpServletResponse response)` Performs exception handling by attempting to render the Errors view.
`protected void` | `renderMergedOutputModel(java.util.Map model, HttpServletRequest request, HttpServletResponse response)` Delegates to renderMergedOutputModel(..)
`protected void` | `renderWithTemplateEngine(GroovyPagesTemplateEngine engine, java.util.Map model, HttpServletResponse response, HttpServletRequest request)` Replaces the requirement for "super.exposeModelAsRequestAttributes(model, request);" in renderMergedOutputModel.
`void` | `setTemplateEngine(GroovyPagesTemplateEngine templateEngine)`

Field Detail

### EXCEPTION_MODEL_KEY

    public static final java.lang.String EXCEPTION_MODEL_KEY

Method Detail

### createResponseWriter

    protected java.io.Writer createResponseWriter(HttpServletResponse response)

  Creates the Response Writer for the specified HttpServletResponse instance.
  Parameters:
    `response` - The HttpServletResponse instance
  Returns:
    A response Writer

### handleException

    protected void handleException(java.lang.Exception exception, @SuppressWarnings("unused") java.io.Writer out, @SuppressWarnings("unused") GroovyPagesTemplateEngine engine, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") 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

### renderMergedOutputModel

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Override
    protected final void renderMergedOutputModel(java.util.Map model, HttpServletRequest request, HttpServletResponse response)

  Delegates to renderMergedOutputModel(..)
  throws:
    Exception When an error occurs rendering the view
  Parameters:
    `model` - The view model
    `request` - The HttpServletRequest
    `response` - The HttpServletResponse
  See Also:
    renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

### renderWithTemplateEngine

    @SuppressWarnings("rawtypes")
    protected void renderWithTemplateEngine(GroovyPagesTemplateEngine engine, java.util.Map model, HttpServletResponse response, HttpServletRequest request)

  Replaces the requirement for "super.exposeModelAsRequestAttributes(model, request);" in renderMergedOutputModel. not in use, since causes bugs, could improve performance
  Override:
    public Object getAttribute(String name) { Object value = super.getAttribute(name); if (value == null) { return model.get(name); } return value; }
  Override:
    public Enumeration<?> getAttributeNames() { return CollectionUtils.append(super.getAttributeNames(), CollectionUtils.asEnumeration(model.keySet().iterator())); }
  Override:
    public void removeAttribute(String name) { super.removeAttribute(name); model.remove(name); }
  Override:
    public void setAttribute(String name, Object o) { super.setAttribute(name, o); if (o == null) { model.remove(name); } } }
  Authors:
    Lari Hotari private static class ModelExposingHttpRequestWrapper extends HttpServletRequestWrapper { Map model; public ModelExposingHttpRequestWrapper(HttpServletRequest request, Map model) { super(request); this.model = model; }

### setTemplateEngine

    public void setTemplateEngine(GroovyPagesTemplateEngine templateEngine)

Groovy Documentation