| java.lang.Object org.apache.velocity.tools.view.ImportSupport org.apache.velocity.tools.struts.TilesTool
TilesTool | public class TilesTool extends ImportSupport (Code) | | View tool to use struts-tiles with Velocity.
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:
<tool>
<key>tiles</key>
<scope>request</scope>
<class>org.apache.velocity.tools.struts.TilesTool</class>
</tool>
This tool should only be used in the request scope.
author: Marino A. Jonsson since: VelocityTools 1.1 version: $Revision: 477914 $ $Date: 2006-11-21 13:52:11 -0800 (Tue, 21 Nov 2006) $ |
Constructor Summary | |
public | TilesTool() Default constructor. |
Method Summary | |
protected String | doInsert(String page, String role, Controller controller) Use this if there is no nested tile. | protected String | doInsert(Map attributes, String page, String role, Controller controller) Use this if there is a nested tile. | protected String | doInsert(ComponentContext subCompContext, String page, String role, Controller controller) | public String | get(Object obj) A generic tiles insert function. | public Object | getAttribute(String name) Fetches a named attribute-value from the current tiles-context. | protected ComponentContext | getCurrentContext() Retrieve the current tiles component context. | public void | importAttribute(String name) Imports the named attribute-value from the current tiles-context into the
current Velocity context. | public 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"). | public void | importAttributes() Imports all attributes in the current tiles-context into the
current velocity-context. | public void | importAttributes(String scope) Imports all attributes in the current tiles-context into the named
context ("page", "request", "session", or "application"). | public void | init(Object obj) Initializes this tool. | protected void | popTilesContext() Pops the tiles sub-context off the context-stack after the lower level
tiles have been rendered. | protected String | processAsDefinitionOrURL(String name) Try to process name as a definition, or as an URL if not found.
Parameters: name - Name to process. | protected String | processDefinition(ComponentDefinition definition) End of Process for definition.
Parameters: definition - Definition to process. | protected String | processObjectValue(Object value) Process an object retrieved as a bean or attribute.
Parameters: value - - Object can be a typed attribute, a String, or anythingelse. | protected String | processTypedAttribute(AttributeDefinition value) Process typed attribute according to its type.
Parameters: value - Typed attribute to process. | protected String | processUrl(String url) Processes an url
Parameters: url - the URI to process. | protected void | pushTilesContext() pushes the current tiles context onto the context-stack. |
APPLICATION_SCOPE | final static String APPLICATION_SCOPE(Code) | | |
LOG | final protected static Log LOG(Code) | | |
contextStack | protected Stack contextStack(Code) | | A stack to hold ComponentContexts while nested tile-definitions
are rendered.
|
TilesTool | public TilesTool()(Code) | | Default constructor. Tool must be initialized before use.
|
doInsert | protected String doInsert(String page, String role, Controller controller) throws Exception(Code) | | Use this if there is no nested tile.
Parameters: page - the page to process. Parameters: role - possible user-role Parameters: controller - possible tiles-controller the rendered template as String. throws: Exception - |
doInsert | protected String doInsert(Map attributes, String page, String role, Controller controller) throws Exception(Code) | | Use this if there is a nested tile.
Parameters: attributes - attributes for the sub-context Parameters: page - the page to process. Parameters: role - possible user-role Parameters: controller - possible tiles-controller the rendered template as String. throws: Exception - |
doInsert | protected String doInsert(ComponentContext subCompContext, String page, String role, Controller controller) throws Exception(Code) | | An extension of the other two doInsert functions
Parameters: subCompContext - the sub-context to set in scope when thetemplate is rendered. Parameters: page - the page to process. Parameters: role - possible user-role Parameters: controller - possible tiles-controller the rendered template as String. throws: Exception - |
get | public String get(Object obj)(Code) | | A generic tiles insert function.
This is functionally equivalent to
<tiles:insert attribute="foo" /> .
Parameters: 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 throws: Exception - on failure |
getAttribute | public Object getAttribute(String name)(Code) | | Fetches a named attribute-value from the current tiles-context.
This is functionally equivalent to
<tiles:getAsString name="foo" /> .
Parameters: name - the name of the tiles-attribute to fetch attribute value for the named attribute |
getCurrentContext | protected ComponentContext getCurrentContext()(Code) | | Retrieve the current tiles component context.
This is pretty much just a convenience method.
|
importAttribute | public void importAttribute(String name)(Code) | | Imports the named attribute-value from the current tiles-context into the
current Velocity context.
This is functionally equivalent to
<tiles:importAttribute name="foo" />
Parameters: name - the name of the tiles-attribute to import |
importAttribute | public void importAttribute(String name, String scope)(Code) | | 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" />
Parameters: name - the name of the tiles-attribute to import Parameters: scope - the named context scope to put the attribute into. |
importAttributes | public void importAttributes()(Code) | | Imports all attributes in the current tiles-context into the
current velocity-context.
This is functionally equivalent to
<tiles:importAttribute /> .
|
importAttributes | public void importAttributes(String scope)(Code) | | 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" /> .
Parameters: scope - the named context scope to put the attributes into. |
popTilesContext | protected void popTilesContext()(Code) | | Pops the tiles sub-context off the context-stack after the lower level
tiles have been rendered.
|
processAsDefinitionOrURL | protected String processAsDefinitionOrURL(String name) throws Exception(Code) | | Try to process name as a definition, or as an URL if not found.
Parameters: name - Name to process. the fully processed definition or URL throws: Exception - |
processDefinition | protected String processDefinition(ComponentDefinition definition) throws Exception(Code) | | End of Process for definition.
Parameters: definition - Definition to process. the fully processed definition. throws: Exception - from InstantiationException Can't create requested controller |
processObjectValue | protected String processObjectValue(Object value) throws Exception(Code) | | Process an object retrieved as a bean or attribute.
Parameters: value - - Object can be a typed attribute, a String, or anythingelse. If typed attribute, use associated type. Otherwise, applytoString() on object, and use returned string as a name. throws: Exception - - Throws by underlying nested call toprocessDefinitionName() the fully processed value as String |
processTypedAttribute | protected String processTypedAttribute(AttributeDefinition value) throws Exception(Code) | | Process typed attribute according to its type.
Parameters: value - Typed attribute to process. the fully processed attribute value as String. throws: Exception - - Throws by underlying nested call to processDefinitionName() |
pushTilesContext | protected void pushTilesContext()(Code) | | 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
|
|
|