类 TilesTool
The TilesTool is used to interact with the Struts-Tiles framework that is part of Struts 1.
Template example(s): <!-- insert a tile --> $tiles.myTileDefinition <!-- get named attribute value from the current tiles-context --> $tiles.getAttribute("myTileAttribute") <!-- import all attributes of the current tiles-context into the velocity-context. --> $tiles.importAttributes() Toolbox configuration: <tools> <toolbox scope="request"> <tool class="org.apache.velocity.tools.struts.TilesTool"/> </toolbox> </tools>
This tool may only be used in the request scope.
- 从以下版本开始:
- VelocityTools 1.1
- 版本:
- $Revision: 601976 $ $Date: 2007-12-06 19:50:51 -0800 (Thu, 06 Dec 2007) $
- 作者:
- Marino A. Jonsson
-
嵌套类概要
从类继承的嵌套类/接口 org.apache.velocity.tools.view.ImportSupport
ImportSupport.ImportResponseWrapper, ImportSupport.SafeClosingHttpURLConnectionReader
-
字段概要
字段修饰符和类型字段说明(专用程序包) static final String
protected boolean
Indicates if there is a MethodExceptionEventHandler presentprotected Stack
A stack to hold ComponentContexts while nested tile-definitions are rendered.(专用程序包) static final String
(专用程序包) static final String
(专用程序包) static final String
protected org.apache.velocity.context.Context
从类继承的字段 org.apache.velocity.tools.view.ImportSupport
application, DEFAULT_ENCODING, LOG, request, response, VALID_SCHEME_CHARS
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected String
An extension of the other two doInsert functionsprotected String
Use this if there is no nested tile.protected String
Use this if there is a nested tile.A generic tiles insert function.getAttribute
(String name) Fetches a named attribute-value from the current tiles-context.protected ComponentContext
Retrieve the current tiles component context.void
importAttribute
(String name) Imports the named attribute-value from the current tiles-context into the current Velocity context.void
importAttribute
(String name, String scope) Imports the named attribute-value from the current tiles-context into the named context ("page", "request", "session", or "application").void
Imports all attributes in the current tiles-context into the current velocity-context.void
importAttributes
(String scope) Imports all attributes in the current tiles-context into the named context ("page", "request", "session", or "application").void
已过时。protected void
Pops the tiles sub-context off the context-stack after the lower level tiles have been rendered.protected String
Try to process name as a definition, or as an URL if not found.protected String
processDefinition
(ComponentDefinition definition) End of Process for definition.protected String
processObjectValue
(Object value) Process an object retrieved as a bean or attribute.protected String
processTypedAttribute
(AttributeDefinition value) Process typed attribute according to its type.protected String
processUrl
(String url) Processes an urlprotected void
pushes the current tiles context onto the context-stack.void
setCatchExceptions
(boolean catchExceptions) void
setVelocityContext
(org.apache.velocity.context.Context context) Initializes this tool.从类继承的方法 org.apache.velocity.tools.view.ImportSupport
acquireReader, acquireString, getContentTypeAttribute, isAbsoluteUrl, setLog, setRequest, setResponse, setServletContext, stripSession
-
字段详细资料
-
PAGE_SCOPE
- 另请参阅:
-
REQUEST_SCOPE
- 另请参阅:
-
SESSION_SCOPE
- 另请参阅:
-
APPLICATION_SCOPE
- 另请参阅:
-
velocityContext
protected org.apache.velocity.context.Context velocityContext -
contextStack
A stack to hold ComponentContexts while nested tile-definitions are rendered. -
catchExceptions
protected boolean catchExceptionsIndicates if there is a MethodExceptionEventHandler present
-
-
构造器详细资料
-
TilesTool
public TilesTool()
-
-
方法详细资料
-
init
已过时。Constructors -
setVelocityContext
public void setVelocityContext(org.apache.velocity.context.Context context) Initializes this tool.- 参数:
context
- the currentContext
- 抛出:
IllegalArgumentException
- if the param is not aContext
-
setCatchExceptions
public void setCatchExceptions(boolean catchExceptions) -
get
A generic tiles insert function.This is functionally equivalent to
<tiles:insert attribute="foo" />
.- 参数:
obj
- Can be any of the following: AttributeDefinition, tile-definition name, tile-attribute name, regular uri. (checked in that order)- 返回:
- the rendered template or value as a String
- 抛出:
Exception
- on failure
-
getAttribute
Fetches a named attribute-value from the current tiles-context.This is functionally equivalent to
<tiles:getAsString name="foo" />
.- 参数:
name
- the name of the tiles-attribute to fetch- 返回:
- attribute value for the named attribute
-
importAttribute
Imports the named attribute-value from the current tiles-context into the current Velocity context.This is functionally equivalent to
<tiles:importAttribute name="foo" />
- 参数:
name
- the name of the tiles-attribute to import
-
importAttribute
Imports the named attribute-value from the current tiles-context into the named context ("page", "request", "session", or "application").This is functionally equivalent to
<tiles:importAttribute name="foo" scope="scopeValue" />
- 参数:
name
- the name of the tiles-attribute to importscope
- the named context scope to put the attribute into.
-
importAttributes
public void importAttributes()Imports all attributes in the current tiles-context into the current velocity-context.This is functionally equivalent to
<tiles:importAttribute />
. -
importAttributes
Imports all attributes in the current tiles-context into the named context ("page", "request", "session", or "application").This is functionally equivalent to
<tiles:importAttribute scope="scopeValue" />
.- 参数:
scope
- the named context scope to put the attributes into.
-
processObjectValue
Process an object retrieved as a bean or attribute.- 参数:
value
- - Object can be a typed attribute, a String, or anything else. If typed attribute, use associated type. Otherwise, apply toString() on object, and use returned string as a name.- 返回:
- the fully processed value as String
- 抛出:
Exception
- - Throws by underlying nested call to processDefinitionName()
-
processTypedAttribute
Process typed attribute according to its type.- 参数:
value
- Typed attribute to process.- 返回:
- the fully processed attribute value as String.
- 抛出:
Exception
- - Throws by underlying nested call to processDefinitionName()
-
processAsDefinitionOrURL
Try to process name as a definition, or as an URL if not found.- 参数:
name
- Name to process.- 返回:
- the fully processed definition or URL
- 抛出:
Exception
-
processDefinition
End of Process for definition.- 参数:
definition
- Definition to process.- 返回:
- the fully processed definition.
- 抛出:
Exception
- from InstantiationException Can't create requested controller
-
processUrl
Processes an url- 参数:
url
- the URI to process.- 返回:
- the rendered template as String.
- 抛出:
Exception
-
doInsert
Use this if there is no nested tile.- 参数:
page
- the page to process.role
- possible user-rolecontroller
- possible tiles-controller- 返回:
- the rendered template as String.
- 抛出:
Exception
-
doInsert
protected String doInsert(Map attributes, String page, String role, Controller controller) throws Exception Use this if there is a nested tile.- 参数:
attributes
- attributes for the sub-contextpage
- the page to process.role
- possible user-rolecontroller
- possible tiles-controller- 返回:
- the rendered template as String.
- 抛出:
Exception
-
doInsert
protected String doInsert(ComponentContext subCompContext, String page, String role, Controller controller) throws Exception An extension of the other two doInsert functions- 参数:
subCompContext
- the sub-context to set in scope when the template is rendered.page
- the page to process.role
- possible user-rolecontroller
- possible tiles-controller- 返回:
- the rendered template as String.
- 抛出:
Exception
-
getCurrentContext
protected ComponentContext getCurrentContext()Retrieve the current tiles component context. This is pretty much just a convenience method. -
pushTilesContext
protected void pushTilesContext()pushes the current tiles context onto the context-stack. preserving the context is necessary so that a sub-context can be put into request scope and lower level tiles can be rendered
-
popTilesContext
protected void popTilesContext()Pops the tiles sub-context off the context-stack after the lower level tiles have been rendered.
-