TilesTool Reference Documentation
The TilesTool is used to interact with the Tiles framework that is now part
of Struts (since v. 1.1).
@@@version@@@, @@@date@@@org.apache.velocity.tools.struts.TilesTool$tilesMarino A. Jonsson<tool>
<key>tiles</key>
<scope>request</scope>
<class>org.apache.velocity.tools.struts.TilesTool</class>
</tool>The Javadoc
for more info.
importAttributes()
Imports all attributes in the current tiles definition into the named context
void importAttributes()
void importAttributes(String scope)
The named context scope to put the attributes into. Possible values
are page
(velocity-context), request
,
session
, and application
.
This method makes it possible to import all attributes, defined in the
current tiles definition, into any scope, to be accessed i.e. by
other tiles.
Assuming that the tiles config contains the following definition(and ".tilename"
is the current tiles definition):
<definition name=".tilename" path="/layout.vm">
<put name="attr1" value="This is one attribute."/>
<put name="attr2" value="and this is a another."/>
</definition>then the following Velocity script:
$tiles.importAttributes()
$attr1
$attr2produces this output:
This is one attribute
and this is another one
getAttribute()
Returns a named tiles attribute from the current tiles definition
String getAttribute(String attributeName)
The name of the tiles-definition attribute.
Returns the named tiles attribute from the current tiles definition
This method makes it possible to fetch any attribute defined in the
current tiles definition.
Assuming that the tiles config contains the following definition (and ".tilename"
is the current tiles definition):
<definition name=".tilename" path="/layout.vm">
<put name="attr1" value="This is one attribute."/>
<put name="attr2" value="and this is a another."/>
</definition>then the following Velocity script:
$tiles.getAttribute("attr1")produces this output:
This is one attribute
importAttribute()
Imports a named attribute in the current tiles definition into the
named context.
void importAttribute(String attributeName)
void importAttribute(String attributeName, String scope)
The name of the tiles-definition attribute.
The named context scope to put the attributes into. Possible values
are page
(velocity-context), request
,
session
, and application
.
This method makes it possible to import a named attribute, defined
in the current tiles definition, into any scope, to be accessed i.e. by
other tiles.
Assuming that the tiles config contains the following definition(and ".tilename"
is the current tiles definition):
<definition name=".tilename" path="/layout.vm">
<put name="attr1" value="This is one attribute."/>
<put name="attr2" value="and this is a another."/>
</definition>then the following Velocity script:
$tiles.importAttribute("attr1")
$attr1produces this output:
This is one attribute
get()
Inserts the named tile into the current tile.
void get(Object attr)
The name of the tile to insert.
This method makes it possible to insert a named tile, defined
in the current tiles definition, into the velocity template.
Assuming that the tiles config contains the following definition(and ".tilename"
is the current tiles definition):
<definition name=".tilename" path="/layout.vm">
<put name="header" value="/header.vm"/>
</definition>then the following two Velocity scripts:
<!-- layout.vm -->
<html>
$tiles.header
<body>
World
</body>
</html>
<!-- header.vm -->
<head>
<title>Hello</title>
</head>produce this output:
<html>
<head>
<title>Hello</title>
</head>
<body>
World
</body>
</html>