|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.view.AbstractView
Abstract view superclass. Standard framework view implementations and application-specific custom views can extend this class to simplify their implementation. Subclasses should be JavaBeans.
Extends ApplicationObjectSupport, which will be helpful to some views. Handles static attributes, and merging static with dynamic attributes. Subclasses just need to implement the actual rendering.
It's recommended that subclasses don't cache anything, in the quest for efficiency. This class offers caching. However, it's possible to disable this class's caching, which is useful during development.
renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
Field Summary |
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
logger |
Constructor Summary | |
AbstractView()
|
Method Summary | |
void |
addStaticAttribute(java.lang.String name,
java.lang.Object value)
Add static data to this view, exposed in each view. |
java.lang.String |
getBeanName()
Return the view's name. |
protected java.lang.String |
getContentType()
Return the content type for this view. |
java.util.Map |
getStaticAttributes()
Handy for testing. |
void |
render(java.util.Map model,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Prepares the view given the specified model, merging it with static attributes and a RequestContext attribute, if necessary. |
protected abstract void |
renderMergedOutputModel(java.util.Map model,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Subclasses must implement this method to render the view. |
void |
setAttributes(java.util.Properties props)
Set static attributes from a java.util.Properties object. |
void |
setAttributesCSV(java.lang.String propString)
Set static attributes as a CSV string. |
void |
setAttributesMap(java.util.Map attributes)
Set static attributes from a Map. |
void |
setBeanName(java.lang.String beanName)
Set the view's name. |
void |
setContentType(java.lang.String contentType)
Set the content type for this view. |
void |
setRequestContextAttribute(java.lang.String requestContextAttribute)
Set the name of the RequestContext attribute for this view, or null if not needed. |
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
getServletContext, getTempDir, getWebApplicationContext, requiredContextClass |
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
getApplicationContext, getMessageSourceAccessor, initApplicationContext, setApplicationContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbstractView()
Method Detail |
public void setBeanName(java.lang.String beanName)
setBeanName
in interface BeanNameAware
beanName
- the view's name. May not be null.
Views should use this for log messages.public java.lang.String getBeanName()
public void setContentType(java.lang.String contentType)
contentType
- content type for this viewprotected java.lang.String getContentType()
public void setRequestContextAttribute(java.lang.String requestContextAttribute)
requestContextAttribute
- name of the RequestContext attributepublic void setAttributes(java.util.Properties props)
Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.
PropertiesEditor
public void setAttributesMap(java.util.Map attributes)
Can be populated with a "map" or "props" element in XML bean definitions.
attributes
- Map with name Strings as keys and attribute
objects as valuespublic void setAttributesCSV(java.lang.String propString) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void addStaticAttribute(java.lang.String name, java.lang.Object value)
Must be invoked before any calls to render().
name
- name of attribute to exposevalue
- object to exposepublic java.util.Map getStaticAttributes()
public void render(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
render
in interface View
model
- Map of model attributes (model name String mapped to model object)request
- current HTTP requestresponse
- HTTP response we are building
java.lang.Exception
- if rendering failedrenderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected abstract void renderMergedOutputModel(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
The first take will be preparing the request: This may include setting the model elements as request attributes, e.g. in the case of a JSP view.
model
- combined output Map, with dynamic values taking precedence
over static attributesrequest
- current HTTP requestresponse
- current HTTP response
java.lang.Exception
- if rendering failed
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |