org.randomcoder.springmvc
Class JstlTemplateView

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.springframework.web.servlet.view.InternalResourceView
                      extended by org.springframework.web.servlet.view.JstlView
                          extended by org.randomcoder.springmvc.JstlTemplateView
All Implemented Interfaces:
BeanNameAware, InitializingBean, ApplicationContextAware, ServletContextAware, View

public class JstlTemplateView
extends JstlView

Custom JSTL-based template view.

 Copyright (c) 2006, Craig Condit. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 
   * Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided with the distribution.
     
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.
 


Field Summary
 
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
JstlTemplateView()
           
 
Method Summary
protected  void exposeHelpers(HttpServletRequest request)
          Adds the template map to the request attribute named by setTemplateName(String).
protected  String getTemplateName()
          Gets the request attribute to store the template map under.
 String getUrl()
          Gets the URL associated with this view.
protected  void populateTemplateMap(Map<String,Object> templateMap)
          Populates the given template map with attributes for this template.
 void setAttributes(Map<String,Object> attributes)
          Sets the attributes to add to this template.
 void setParent(JstlTemplateView parent)
          Sets the parent template of this template.
 void setTemplateName(String templateName)
          Sets the name of the request attribute to populate with the template map.
 void setUrl(String url)
          Sets the URL for this view.
 
Methods inherited from class org.springframework.web.servlet.view.JstlView
initApplicationContext
 
Methods inherited from class org.springframework.web.servlet.view.InternalResourceView
exposeForwardRequestAttributes, prepareForRendering, renderMergedOutputModel, setAlwaysInclude, useInclude
 
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
afterPropertiesSet, 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, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JstlTemplateView

public JstlTemplateView()
Method Detail

setAttributes

public void setAttributes(Map<String,Object> attributes)
Sets the attributes to add to this template.

Parameters:
attributes - map of attribute key/value pairs.

getUrl

public String getUrl()
Gets the URL associated with this view.

Delegates to the parent view if no url was specified.

Overrides:
getUrl in class AbstractUrlBasedView
Returns:
url

setUrl

public void setUrl(String url)
Sets the URL for this view.

Overrides:
setUrl in class AbstractUrlBasedView
Parameters:
url - url

setTemplateName

public void setTemplateName(String templateName)
Sets the name of the request attribute to populate with the template map.

Parameters:
templateName - template name (defaults to "template")

setParent

public void setParent(JstlTemplateView parent)
Sets the parent template of this template.

Several methods in this class delegate to the parent.

Parameters:
parent - parent template

exposeHelpers

protected void exposeHelpers(HttpServletRequest request)
                      throws Exception
Adds the template map to the request attribute named by setTemplateName(String).

Overrides:
exposeHelpers in class JstlView
Parameters:
request - HTTP request
Throws:
Exception - if an error occurs

populateTemplateMap

protected void populateTemplateMap(Map<String,Object> templateMap)
Populates the given template map with attributes for this template.

This method merges the template map with that of the parent view if it is found.

Parameters:
templateMap - map of key / value pairs

getTemplateName

protected String getTemplateName()
Gets the request attribute to store the template map under.

This method delegates to the parent template if no name is found.

Returns:
template name


Copyright © 2006-2010 Craig Condit. All Rights Reserved.