类 VelocityToolboxView
- 所有已实现的接口:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.web.context.ServletContextAware,org.springframework.web.servlet.View
VelocityView subclass which adds support for Velocity Tools toolboxes
and Velocity Tools ViewTool callbacks / Velocity Tools 1.3 init methods.
Specify a "toolboxConfigLocation", for example "/WEB-INF/toolbox.xml", to automatically load a Velocity Tools toolbox definition file and expose all defined tools in the specified scopes. If no config location is specified, no toolbox will be loaded and exposed.
This view will always create a special Velocity context, namely an instance of the ChainedContext class which is part of the view package of Velocity tools. This allows to use tools from the view package of Velocity Tools, like LinkTool, which need to be initialized with a special context that implements the ViewContext interface (i.e. a ChainedContext).
This view also checks tools that are specified as "toolAttributes":
If they implement the ViewTool interface, they will get initialized with
the Velocity context. This allows tools from the view package of Velocity
Tools, such as LinkTool, to be defined as
"toolAttributes" on a VelocityToolboxView,
instead of in a separate toolbox XML file.
This is a separate class mainly to avoid a required dependency on
the view package of Velocity Tools in VelocityView itself.
As of Spring 3.0, this class requires Velocity Tools 1.3 or higher.
- 从以下版本开始:
- 1.1.3
- 作者:
- Juergen Hoeller
- 另请参阅:
-
字段概要
从类继承的字段 org.springframework.web.servlet.view.AbstractTemplateView
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE从类继承的字段 org.springframework.web.servlet.view.AbstractView
DEFAULT_CONTENT_TYPE从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger从接口继承的字段 org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected org.apache.velocity.context.ContextcreateVelocityContext(Map<String, Object> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Overridden to create a ChainedContext, which is part of the view package of Velocity Tools, as special context.protected StringReturn the Velocity Toolbox config location, if any.protected voidOverridden to check for the ViewContext interface which is part of the view package of Velocity Tools.voidsetToolboxConfigLocation(String toolboxConfigLocation) Set a Velocity Toolbox config location, for example "/WEB-INF/toolbox.xml", to automatically load a Velocity Tools toolbox definition file and expose all defined tools in the specified scopes.从类继承的方法 cn.aradin.spring.velocity.view.VelocityView
autodetectVelocityEngine, checkResource, createVelocityContext, doRender, exposeHelpers, exposeHelpers, exposeHelpers, exposeToolAttributes, getEncoding, getTemplate, getTemplate, getVelocityEngine, initApplicationContext, isCacheTemplate, mergeTemplate, renderMergedTemplateModel, setCacheTemplate, setDateToolAttribute, setEncoding, setNumberToolAttribute, setToolAttributes, setVelocityEngine从类继承的方法 org.springframework.web.servlet.view.AbstractTemplateView
applyContentType, renderMergedOutputModel, setAllowRequestOverride, setAllowSessionOverride, setExposeRequestAttributes, setExposeSessionAttributes, setExposeSpringMacroHelpers从类继承的方法 org.springframework.web.servlet.view.AbstractUrlBasedView
afterPropertiesSet, getUrl, isUrlRequired, setUrl, toString从类继承的方法 org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext
-
构造器详细资料
-
VelocityToolboxView
public VelocityToolboxView()
-
-
方法详细资料
-
setToolboxConfigLocation
Set a Velocity Toolbox config location, for example "/WEB-INF/toolbox.xml", to automatically load a Velocity Tools toolbox definition file and expose all defined tools in the specified scopes. If no config location is specified, no toolbox will be loaded and exposed.The specified location string needs to refer to a ServletContext resource, as expected by ServletToolboxManager which is part of the view package of Velocity Tools.
- 参数:
toolboxConfigLocation- toolboxConfigLocation
-
getToolboxConfigLocation
Return the Velocity Toolbox config location, if any.- 返回:
- toolboxConfigLocation
-
createVelocityContext
protected org.apache.velocity.context.Context createVelocityContext(Map<String, Object> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws ExceptionOverridden to create a ChainedContext, which is part of the view package of Velocity Tools, as special context. ChainedContext is needed for initialization of ViewTool instances.- 覆盖:
createVelocityContext在类中VelocityView- 参数:
model- the model Map, containing the model attributes to be exposed to the viewrequest- current HTTP requestresponse- current HTTP response- 返回:
- the Velocity Context
- 抛出:
Exception- if there's a fatal error while creating the context- 另请参阅:
-
initTool
protected void initTool(Object tool, org.apache.velocity.context.Context velocityContext) throws Exception Overridden to check for the ViewContext interface which is part of the view package of Velocity Tools. This requires a special Velocity context, like ChainedContext as set up bycreateVelocityContext(java.util.Map<java.lang.String, java.lang.Object>, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)in this class.- 覆盖:
initTool在类中VelocityView- 参数:
tool- the tool instance to initializevelocityContext- the Velocity context- 抛出:
Exception- if initializion of the tool failed- 另请参阅:
-