Save This Page
Home » spring-framework-2.5.4 » org.springframework » web » servlet » view » [javadoc | source]
org.springframework.web.servlet.view
abstract public class: AbstractView [javadoc | source]
java.lang.Object
   org.springframework.context.support.ApplicationObjectSupport
      org.springframework.web.context.support.WebApplicationObjectSupport
         org.springframework.web.servlet.view.AbstractView

All Implemented Interfaces:
    View, BeanNameAware, ServletContextAware, ApplicationContextAware

Direct Known Subclasses:
    AbstractXsltView, TilesView, XsltView, InternalResourceView, FreeMarkerView, AbstractTemplateView, JasperReportsMultiFormatView, TilesJstlView, JasperReportsPdfView, JasperReportsCsvView, VelocityLayoutView, AbstractJasperReportsView, JasperReportsXlsView, AbstractJasperReportsSingleFormatView, AbstractPdfView, VelocityView, AbstractJExcelView, AbstractUrlBasedView, ConfigurableJasperReportsView, JstlView, VelocityToolboxView, TilesView, JasperReportsHtmlView, AbstractExcelView, RedirectView

Abstract base class for org.springframework.web.servlet.View implementations. Subclasses should be JavaBeans, to allow for convenient configuration as Spring-managed bean instances.

Provides support for static attributes, to be made available to the view, with a variety of ways to specify them. Static attributes will be merged with the given dynamic attributes (the model that the controller returned) for each render operation.

Extends WebApplicationObjectSupport , which will be helpful to some views. Subclasses just need to implement the actual rendering.

Field Summary
public static final  String DEFAULT_CONTENT_TYPE    Default content type. Overridable as bean property. 
Fields inherited from org.springframework.context.support.ApplicationObjectSupport:
logger
Method from org.springframework.web.servlet.view.AbstractView Summary:
addStaticAttribute,   createRequestContext,   exposeModelAsRequestAttributes,   generatesDownloadContent,   getAttributesMap,   getBeanName,   getContentType,   getRequestContextAttribute,   getStaticAttributes,   prepareResponse,   render,   renderMergedOutputModel,   setAttributes,   setAttributesCSV,   setAttributesMap,   setBeanName,   setContentType,   setRequestContextAttribute,   toString
Methods from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContext,   getTempDir,   getWebApplicationContext,   initApplicationContext,   initServletContext,   isContextRequired,   setServletContext
Methods from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContext,   getMessageSourceAccessor,   initApplicationContext,   initApplicationContext,   isContextRequired,   requiredContextClass,   setApplicationContext
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.servlet.view.AbstractView Detail:
 public  void addStaticAttribute(String name,
    Object value) 
    Add static data to this view, exposed in each view.

    "Static" attributes are fixed attributes that are specified in the View instance configuration. "Dynamic" attributes, on the other hand, are values passed in as part of the model.

    Must be invoked before any calls to render.

 protected RequestContext createRequestContext(HttpServletRequest request,
    Map model) 
    Create a RequestContext to expose under the specified attribute name.

    Default implementation creates a standard RequestContext instance for the given request and model. Can be overridden in subclasses for custom instances.

 protected  void exposeModelAsRequestAttributes(Map model,
    HttpServletRequest request) throws Exception 
    Expose the model objects in the given map as request attributes. Names will be taken from the model Map. This method is suitable for all resources reachable by javax.servlet.RequestDispatcher .
 protected boolean generatesDownloadContent() 
    Return whether this view generates download content (typically binary content like PDF or Excel files).

    The default implementation returns false. Subclasses are encouraged to return true here if they know that they are generating download content that requires temporary caching on the client side, typically via the response OutputStream.

 public Map getAttributesMap() 
    Allow Map access to the static attributes of this view, with the option to add or override specific entries.

    Useful for specifying entries directly, for example via "attributesMap[myKey]". This is particularly useful for adding or overriding entries in child view definitions.

 public String getBeanName() 
    Return the view's name. Should never be null, if the view was correctly configured.
 public String getContentType() 
    Return the content type for this view.
 public String getRequestContextAttribute() 
    Return the name of the RequestContext attribute, if any.
 public Map getStaticAttributes() 
    Return the static attributes for this view. Handy for testing.

    Returns an unmodifiable Map, as this is not intended for manipulating the Map but rather just for checking the contents.

 protected  void prepareResponse(HttpServletRequest request,
    HttpServletResponse response) 
    Prepare the given response for rendering.

    The default implementation applies a workaround for an IE bug when sending download content via HTTPS.

 public  void render(Map model,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception 
    Prepares the view given the specified model, merging it with static attributes and a RequestContext attribute, if necessary. Delegates to renderMergedOutputModel for the actual rendering.
 abstract protected  void renderMergedOutputModel(Map model,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception
    Subclasses must implement this method to actually render the view.

    The first step will be preparing the request: In the JSP case, this would mean setting model objects as request attributes. The second step will be the actual rendering of the view, for example including the JSP via a RequestDispatcher.

 public  void setAttributes(Properties attributes) 
    Set static attributes for this view from a java.util.Properties object.

    "Static" attributes are fixed attributes that are specified in the View instance configuration. "Dynamic" attributes, on the other hand, are values passed in as part of the model.

    This is the most convenient way to set static attributes. Note that static attributes can be overridden by dynamic attributes, if a value with the same name is included in the model.

    Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.

 public  void setAttributesCSV(String propString) throws IllegalArgumentException 
    Set static attributes as a CSV string. Format is: attname0={value1},attname1={value1}

    "Static" attributes are fixed attributes that are specified in the View instance configuration. "Dynamic" attributes, on the other hand, are values passed in as part of the model.

 public  void setAttributesMap(Map attributes) 
    Set static attributes for this view from a Map. This allows to set any kind of attribute values, for example bean references.

    "Static" attributes are fixed attributes that are specified in the View instance configuration. "Dynamic" attributes, on the other hand, are values passed in as part of the model.

    Can be populated with a "map" or "props" element in XML bean definitions.

 public  void setBeanName(String beanName) 
    Set the view's name. Helpful for traceability.

    Framework code must call this when constructing views.

 public  void setContentType(String contentType) 
    Set the content type for this view. Default is "text/html;charset=ISO-8859-1".

    May be ignored by subclasses if the view itself is assumed to set the content type, e.g. in case of JSPs.

 public  void setRequestContextAttribute(String requestContextAttribute) 
    Set the name of the RequestContext attribute for this view. Default is none.
 public String toString()