Class GroovyMarkupView

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

public class GroovyMarkupView extends AbstractTemplateView
An AbstractTemplateView subclass based on Groovy XML/XHTML markup templates.

Spring's Groovy Markup Template support requires Groovy 2.3.1 and higher.

Since:
4.1
Author:
Brian Clozel, Rossen Stoyanchev
See Also:
  • Constructor Details

    • GroovyMarkupView

      public GroovyMarkupView()
  • Method Details

    • setTemplateEngine

      public void setTemplateEngine(groovy.text.markup.MarkupTemplateEngine engine)
      Set the MarkupTemplateEngine to use in this view.

      If not set, the engine is auto-detected by looking up a single GroovyMarkupConfig bean in the web application context and using it to obtain the configured MarkupTemplateEngine instance.

      See Also:
    • initApplicationContext

      protected void initApplicationContext(ApplicationContext context)
      Invoked at startup. If no templateEngine has been manually set, this method looks up a GroovyMarkupConfig bean by type and uses it to obtain the Groovy Markup template engine.
      Overrides:
      initApplicationContext in class WebApplicationObjectSupport
      Parameters:
      context - the containing ApplicationContext
      See Also:
    • autodetectMarkupTemplateEngine

      protected groovy.text.markup.MarkupTemplateEngine autodetectMarkupTemplateEngine() throws BeansException
      Autodetect a MarkupTemplateEngine via the ApplicationContext. Called if a MarkupTemplateEngine has not been manually configured.
      Throws:
      BeansException
    • checkResource

      public boolean checkResource(Locale locale) throws Exception
      Description copied from class: AbstractUrlBasedView
      Check whether the underlying resource that the configured URL points to actually exists.
      Overrides:
      checkResource in class AbstractUrlBasedView
      Parameters:
      locale - the desired Locale that we're looking for
      Returns:
      true if the resource exists (or is assumed to exist); false if we know that it does not exist
      Throws:
      Exception - if the resource exists but is invalid (for example, could not be parsed)
    • renderMergedTemplateModel

      protected void renderMergedTemplateModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception
      Description copied from class: AbstractTemplateView
      Subclasses must implement this method to actually render the view.
      Specified by:
      renderMergedTemplateModel in class AbstractTemplateView
      Parameters:
      model - combined output Map, with request attributes and session attributes merged into it if required
      request - current HTTP request
      response - current HTTP response
      Throws:
      Exception - if rendering failed
    • getTemplate

      protected groovy.text.Template getTemplate(String viewUrl) throws Exception
      Return a template compiled by the configured Groovy Markup template engine for the given view URL.
      Throws:
      Exception