Groovy Documentation

org.codehaus.groovy.grails.web.servlet.view
[Java] 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

public class GroovyPageView
extends org.springframework.web.servlet.view.AbstractUrlBasedView

A Spring View that renders Groovy Server Pages to the response. 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

protected groovy.text.Template template

protected GroovyPagesTemplateEngine templateEngine

 
Fields inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
DEFAULT_CONTENT_TYPE, RESPONSE_STATUS_ATTRIBUTE, PATH_VARIABLES
 
Fields inherited from class org.springframework.web.servlet.view.AbstractView
DEFAULT_CONTENT_TYPE, RESPONSE_STATUS_ATTRIBUTE, PATH_VARIABLES
 
Method Summary
void afterPropertiesSet()

static GroovyPagesException createGroovyPageException(java.lang.Exception exception, GroovyPagesTemplateEngine engine, java.lang.String pageUrl)

protected GSPResponseWriter createResponseWriter(javax.servlet.http.HttpServletResponse response)

Creates the Response Writer for the specified HttpServletResponse instance.

protected void handleException(java.lang.Exception exception, GroovyPagesTemplateEngine engine)

Performs exception handling by attempting to render the Errors view.

protected void initTemplate()

boolean isExpired()

protected void renderMergedOutputModel(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

Delegates to renderMergedOutputModel(..)

protected void renderWithTemplateEngine(GroovyPagesTemplateEngine engine, java.util.Map model, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request)

Replaces the requirement for "super.exposeModelAsRequestAttributes(model, request);" in renderMergedOutputModel.

void setScriptSource(org.springframework.scripting.ScriptSource scriptSource)

void setTemplateEngine(GroovyPagesTemplateEngine templateEngine)

 
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
org.springframework.web.servlet.view.AbstractUrlBasedView#toString(), org.springframework.web.servlet.view.AbstractUrlBasedView#checkResource(java.util.Locale), org.springframework.web.servlet.view.AbstractUrlBasedView#getUrl(), org.springframework.web.servlet.view.AbstractUrlBasedView#setUrl(java.lang.String), org.springframework.web.servlet.view.AbstractUrlBasedView#afterPropertiesSet(), org.springframework.web.servlet.view.AbstractUrlBasedView#getContentType(), org.springframework.web.servlet.view.AbstractUrlBasedView#setContentType(java.lang.String), org.springframework.web.servlet.view.AbstractUrlBasedView#render(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), org.springframework.web.servlet.view.AbstractUrlBasedView#setAttributes(java.util.Properties), org.springframework.web.servlet.view.AbstractUrlBasedView#getBeanName(), org.springframework.web.servlet.view.AbstractUrlBasedView#setBeanName(java.lang.String), org.springframework.web.servlet.view.AbstractUrlBasedView#setRequestContextAttribute(java.lang.String), org.springframework.web.servlet.view.AbstractUrlBasedView#getRequestContextAttribute(), org.springframework.web.servlet.view.AbstractUrlBasedView#setAttributesCSV(java.lang.String), org.springframework.web.servlet.view.AbstractUrlBasedView#addStaticAttribute(java.lang.String, java.lang.Object), org.springframework.web.servlet.view.AbstractUrlBasedView#setAttributesMap(java.util.Map), org.springframework.web.servlet.view.AbstractUrlBasedView#getAttributesMap(), org.springframework.web.servlet.view.AbstractUrlBasedView#getStaticAttributes(), org.springframework.web.servlet.view.AbstractUrlBasedView#setExposePathVariables(boolean), org.springframework.web.servlet.view.AbstractUrlBasedView#isExposePathVariables(), org.springframework.web.servlet.view.AbstractUrlBasedView#setServletContext(javax.servlet.ServletContext), org.springframework.web.servlet.view.AbstractUrlBasedView#setApplicationContext(org.springframework.context.ApplicationContext), org.springframework.web.servlet.view.AbstractUrlBasedView#getApplicationContext(), org.springframework.web.servlet.view.AbstractUrlBasedView#wait(), org.springframework.web.servlet.view.AbstractUrlBasedView#wait(long), org.springframework.web.servlet.view.AbstractUrlBasedView#wait(long, int), org.springframework.web.servlet.view.AbstractUrlBasedView#equals(java.lang.Object), org.springframework.web.servlet.view.AbstractUrlBasedView#hashCode(), org.springframework.web.servlet.view.AbstractUrlBasedView#getClass(), org.springframework.web.servlet.view.AbstractUrlBasedView#notify(), org.springframework.web.servlet.view.AbstractUrlBasedView#notifyAll()
 
Methods inherited from class org.springframework.web.servlet.view.AbstractView
org.springframework.web.servlet.view.AbstractView#toString(), org.springframework.web.servlet.view.AbstractView#getContentType(), org.springframework.web.servlet.view.AbstractView#setContentType(java.lang.String), org.springframework.web.servlet.view.AbstractView#render(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), org.springframework.web.servlet.view.AbstractView#setAttributes(java.util.Properties), org.springframework.web.servlet.view.AbstractView#getBeanName(), org.springframework.web.servlet.view.AbstractView#setBeanName(java.lang.String), org.springframework.web.servlet.view.AbstractView#setRequestContextAttribute(java.lang.String), org.springframework.web.servlet.view.AbstractView#getRequestContextAttribute(), org.springframework.web.servlet.view.AbstractView#setAttributesCSV(java.lang.String), org.springframework.web.servlet.view.AbstractView#addStaticAttribute(java.lang.String, java.lang.Object), org.springframework.web.servlet.view.AbstractView#setAttributesMap(java.util.Map), org.springframework.web.servlet.view.AbstractView#getAttributesMap(), org.springframework.web.servlet.view.AbstractView#getStaticAttributes(), org.springframework.web.servlet.view.AbstractView#setExposePathVariables(boolean), org.springframework.web.servlet.view.AbstractView#isExposePathVariables(), org.springframework.web.servlet.view.AbstractView#setServletContext(javax.servlet.ServletContext), org.springframework.web.servlet.view.AbstractView#setApplicationContext(org.springframework.context.ApplicationContext), org.springframework.web.servlet.view.AbstractView#getApplicationContext(), org.springframework.web.servlet.view.AbstractView#wait(), org.springframework.web.servlet.view.AbstractView#wait(long), org.springframework.web.servlet.view.AbstractView#wait(long, int), org.springframework.web.servlet.view.AbstractView#equals(java.lang.Object), org.springframework.web.servlet.view.AbstractView#hashCode(), org.springframework.web.servlet.view.AbstractView#getClass(), org.springframework.web.servlet.view.AbstractView#notify(), org.springframework.web.servlet.view.AbstractView#notifyAll()
 

Field Detail

EXCEPTION_MODEL_KEY

public static final java.lang.String EXCEPTION_MODEL_KEY


template

protected groovy.text.Template template


templateEngine

protected GroovyPagesTemplateEngine templateEngine


 
Method Detail

afterPropertiesSet

@Override
public void afterPropertiesSet()


createGroovyPageException

public static GroovyPagesException createGroovyPageException(java.lang.Exception exception, GroovyPagesTemplateEngine engine, java.lang.String pageUrl)


createResponseWriter

protected GSPResponseWriter createResponseWriter(javax.servlet.http.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, GroovyPagesTemplateEngine engine)
Performs exception handling by attempting to render the Errors view.
Parameters:
exception - The exception that occured
engine - The GSP engine


initTemplate

@SuppressWarnings("unused")
protected void initTemplate()


isExpired

public boolean isExpired()


renderMergedOutputModel

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected final void renderMergedOutputModel(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.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", "unused" })
protected void renderWithTemplateEngine(GroovyPagesTemplateEngine engine, java.util.Map model, javax.servlet.http.HttpServletResponse response, javax.servlet.http.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; }


setScriptSource

public void setScriptSource(org.springframework.scripting.ScriptSource scriptSource)


setTemplateEngine

public void setTemplateEngine(GroovyPagesTemplateEngine templateEngine)


 

Groovy Documentation