|
||||||||||
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 org.springframework.web.servlet.view.AbstractUrlBasedView org.springframework.web.servlet.view.AbstractTemplateView
public abstract class AbstractTemplateView
AbstractTemplateView provides template based view technologies such as Velocity and FreeMarker, with the ability to use request and session attributes in their model and the option to expose helper objects for Spring's Velocity/FreeMarker macro library.
JSP/JSTL and other view technologies automatically have access to the HttpServletRequest object and thereby the request/session attributes for the current user. Furthermore, they are able to create and cache helper objects as request attributes themselves.
Field Summary | |
---|---|
static String |
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
Variable name of the RequestContext instance in the template model, available to Spring's macros: e.g. for creating BindStatus objects. |
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 | |
---|---|
AbstractTemplateView()
|
Method Summary | |
---|---|
protected void |
renderMergedOutputModel(Map model,
HttpServletRequest request,
HttpServletResponse response)
Subclasses must implement this method to actually render the view. |
protected abstract void |
renderMergedTemplateModel(Map model,
HttpServletRequest request,
HttpServletResponse response)
Subclasses must implement this method to actually render the view. |
void |
setAllowRequestOverride(boolean allowRequestOverride)
Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. |
void |
setAllowSessionOverride(boolean allowSessionOverride)
Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. |
void |
setExposeRequestAttributes(boolean exposeRequestAttributes)
Set whether all request attributes should be added to the model prior to merging with the template. |
void |
setExposeSessionAttributes(boolean exposeSessionAttributes)
Set whether all HttpSession attributes should be added to the model prior to merging with the template. |
void |
setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers)
Set whether to expose a RequestContext for use by Spring's macro library, under the name "springBindRequestContext". |
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView |
---|
afterPropertiesSet, getUrl, setUrl, toString |
Methods inherited from class org.springframework.web.servlet.view.AbstractView |
---|
addStaticAttribute, createRequestContext, 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 |
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
Constructor Detail |
---|
public AbstractTemplateView()
Method Detail |
---|
public void setExposeRequestAttributes(boolean exposeRequestAttributes)
public void setExposeSessionAttributes(boolean exposeSessionAttributes)
public void setAllowRequestOverride(boolean allowRequestOverride)
public void setAllowSessionOverride(boolean allowSessionOverride)
public void setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers)
Currently needed for Spring's Velocity and FreeMarker default macros. Note that this is not required for templates that use HTML forms unless you wish to take advantage of the Spring helper macros.
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
protected final void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception
AbstractView
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.
renderMergedOutputModel
in class AbstractView
model
- combined output Map (never null
),
with dynamic values taking precedence over static attributesrequest
- current HTTP requestresponse
- current HTTP response
Exception
- if rendering failedprotected abstract void renderMergedTemplateModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception
model
- combined output Map, with request attributes and
session attributes merged into it if requiredrequest
- current HTTP requestresponse
- current HTTP response
Exception
- if rendering failed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |