The Velocity Project < Velocity Tools - Struts >

Velocity Tools

VelocityStruts

VelocityStruts Tools

Other Subprojects

StrutsLinkTool Reference Documentation
       

The StrutsLinkTool extends the standard LinkTool to add methods for working with Struts' Actions and Forwards:

Class
 org.apache.velocity.tools.struts.StrutsLinkTool
Name
 $link (this is the recommended name of the tool in the Velocity context)
Toolbox Configuration Example
 
<tool>
  <key>link</key>
  <scope>request</scope>
  <class>org.apache.velocity.tools.struts.StrutsLinkTool</class>
</tool>
Author(s)
  Gabriel Sidler
Nathan Bubna
Method Overview
setAction() Returns a copy of this StrutsLinkTool instance with the given action path converted into a server-relative URI reference.
setForward() Returns a copy of this StrutsLinkTool instance with the given global or local forward name converted into a server-relative URI reference.
See Also
The Javadoc for more info.
setAction()
       

Returns a copy of this StrutsLinkTool instance with the given action path converted into a server-relative URI reference.

StrutsLinkTool setAction(String action)

Parameters
action
An action path as defined in struts-config.xml, e.g. /logon.
Returns
A new instance of StrutsLinkTool.

The action name is translated into a server-relative URI reference. The method does not check if the specified action has been defined. It will overwrite any previously set URI reference but will copy the query string.

## a form tag
<form name="form1" action="$link.setAction("demo")">

Produces something like:

<form name="form1" action="/myapp/demo.do">

setForward()
       

Returns a copy of this StrutsLinkTool instance with the given global or local forward name converted into a server-relative URI reference.

StrutsLinkTool setForward(String forward)

Parameters
forward
The name of a global or local forward as defined in struts-config.xml. (global-forward section for global or within an action mapping for local forwards).
Returns
A new instance of StrutsLinkTool or null if the parameter does not map to a valid forward.

The forward URL is translated into a server-relative URI reference. This method will overwrite any previously set URI reference but will copy the query string.

## a forward
<a href="$link.setForward("start").addQueryData("key1","val 1")">
My Link</a>

Produces something like:

<a href="/myapp/templates/index.vm?key=val+1">My Link</a>


Copyright © 1999-2003, Apache Software Foundation