VelocityStruts
Other Subprojects
The TilesTool is used to interact with the Tiles framework that is now part of Struts (since v. 1.1).
<tool> <key>tiles</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.TilesTool</class> </tool>
void importAttributes()
void importAttributes(String scope)
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 $attr2
produces this output:
This is one attribute and this is another one
String getAttribute(String attributeName)
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
void importAttribute(String attributeName)
void importAttribute(String attributeName, String scope)
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") $attr1
produces this output:
This is one attribute
void get(Object attr)
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>