Class StrutsLinkTool
- java.lang.Object
-
- org.apache.velocity.tools.generic.SafeConfig
-
- org.apache.velocity.tools.generic.LinkTool
-
- org.apache.velocity.tools.view.LinkTool
-
- org.apache.velocity.tools.view.tools.LinkTool
-
- org.apache.velocity.tools.struts.StrutsLinkTool
-
- All Implemented Interfaces:
Cloneable
public class StrutsLinkTool extends LinkTool
The StrutsLinkTool extends the standard
LinkToolto add methods for working with Struts' Actions and Forwards:- translate logical names (Struts forwards, actions ) to URI references, see
methods
setAction(java.lang.String)andsetForward(java.lang.String)
Template example(s): <a href="$link.action.update">update something</a> #set( $base = $link.forward.MyPage.anchor('view') ) <a href="$base.param('select','this')">view this</a> <a href="$base.param('select','that')">view that</a> Toolbox configuration: <tools> <toolbox scope="request"> <tool class="org.apache.velocity.tools.struts.StrutsLinkTool"/> </toolbox> </tools>This tool may only be used in the request scope.
- Version:
- $Id$
- Author:
- Gabe Sidler, Nathan Bubna
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.servlet.ServletContextapplication-
Fields inherited from class org.apache.velocity.tools.view.tools.LinkTool
AUTO_IGNORE_PARAMETERS_KEY, SELF_ABSOLUTE_KEY, SELF_INCLUDE_PARAMETERS_KEY
-
Fields inherited from class org.apache.velocity.tools.view.LinkTool
INCLUDE_REQUEST_PARAMS_KEY, includeRequestParams, request, response
-
Fields inherited from class org.apache.velocity.tools.generic.LinkTool
APPEND_PARAMS_KEY, appendParams, charset, CHARSET_KEY, DEFAULT_CHARSET, DEFAULT_SCHEME, FORCE_RELATIVE_KEY, forceRelative, fragment, FRAGMENT_KEY, host, HOST_KEY, HTML_QUERY_DELIMITER, LOG, opaque, path, PATH_KEY, port, PORT_KEY, query, QUERY_KEY, queryDelim, scheme, SCHEME_KEY, SECURE_SCHEME, self, URI_KEY, user, USER_KEY, XHTML_MODE_KEY, XHTML_QUERY_DELIMITER
-
Fields inherited from class org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, OLD_LOCK_CONFIG_KEY, SAFE_MODE_KEY
-
-
Constructor Summary
Constructors Constructor Description StrutsLinkTool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StrutsLinkToolaction(String action)Returns a copy of the link with the given action name converted into a server-relative URI reference.protected voidconfigure(ValueParser props)Does the actual configuration.StrutsLinkToolforward(String forward)Returns a copy of the link with the given global or local forward name converted into a server-relative URI reference.StrutsLinkToolget(String getme)This exists to enable a simplified syntax for using this tool in a template.StrutsLinkToolsetAction(String action)Returns a copy of the link with the given action name converted into a server-relative URI reference.StrutsLinkToolsetForward(String forward)Returns a copy of the link with the given global or local forward name converted into a server-relative URI reference.-
Methods inherited from class org.apache.velocity.tools.view.tools.LinkTool
addAllParameters, addIgnore, addQueryData, addQueryData, duplicate, encodeURL, getQueryData, getURI, init, setAbsolute, setAnchor, setAutoIgnoreParameters, setParam, setParams, setRelative, setRequest, setResponse, setSelfAbsolute, setSelfIncludeParameters, setURI, setXhtml
-
Methods inherited from class org.apache.velocity.tools.view.LinkTool
addMissingRequestParams, addRequestParams, addRequestParamsExcept, getContextPath, getContextURL, getRequestPath, isPathChanged, setFromRequest, setIncludeRequestParams, toString
-
Methods inherited from class org.apache.velocity.tools.generic.LinkTool
absolute, absolute, anchor, append, append, appendAsArray, appendPath, appendQuery, combinePath, combineQuery, createURI, debug, debug, decode, decodeQueryPercents, directory, duplicate, encode, equals, getAnchor, getAppendParams, getBaseRef, getCharacterEncoding, getDirectory, getFile, getHost, getParams, getPath, getPort, getQuery, getRoot, getScheme, getSelf, getUri, getUser, handleParamsBoolean, hashCode, host, insecure, isAbsolute, isOpaque, isRelative, isSecure, isXHTML, normalizeQuery, param, params, parseQuery, parseQuery, path, port, query, relative, relative, remove, removeParam, root, scheme, secure, set, setAppendParams, setCharacterEncoding, setForceRelative, setFragment, setFromURI, setHost, setPath, setPort, setQuery, setScheme, setUserInfo, setXHTML, toQuery, toQuery, toURI, uri, user
-
Methods inherited from class org.apache.velocity.tools.generic.SafeConfig
configure, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
-
-
-
-
Method Detail
-
configure
protected void configure(ValueParser props)
Description copied from class:SafeConfigDoes the actual configuration. This is protected, so subclasses may share the same ValueParser and call configure at any time, while preventing templates from doing so when configure(Map) is locked.
-
get
public StrutsLinkTool get(String getme)
This exists to enable a simplified syntax for using this tool in a template. Now, users can do
$link.action.saveFooinstead of$link.setAction('saveFoo')and$link.forward.profileinstead of$link.setForward('profile'). Neat, eh? :)- Since:
- VelocityTools 1.3
-
action
public StrutsLinkTool action(String action)
Returns a copy of the link with the given action name converted into a server-relative URI reference. This method does not check if the specified action really is defined. This method will overwrite any previous URI reference settings but will copy the query string.
- Parameters:
action- an action path as defined in struts-config.xml- Returns:
- a new instance of StrutsLinkTool
-
setAction
public StrutsLinkTool setAction(String action)
Returns a copy of the link with the given action name converted into a server-relative URI reference. This method does not check if the specified action really is defined. This method will overwrite any previous URI reference settings but will copy the query string.
- Parameters:
action- an action path as defined in struts-config.xml- Returns:
- a new instance of StrutsLinkTool
-
forward
public StrutsLinkTool forward(String forward)
Returns a copy of the link with the given global or local forward name converted into a server-relative URI reference. If the parameter does not map to an existing global forward name,
nullis returned. This method will overwrite any previous URI reference settings but will copy the query string.- Parameters:
forward- a forward name as defined in struts-config.xml in either global-forwards or in the currently executing action mapping.- Returns:
- a new instance of StrutsLinkTool
-
setForward
public StrutsLinkTool setForward(String forward)
Returns a copy of the link with the given global or local forward name converted into a server-relative URI reference. If the parameter does not map to an existing global forward name,
nullis returned. This method will overwrite any previous URI reference settings but will copy the query string.- Parameters:
forward- a forward name as defined in struts-config.xml in either global-forwards or in the currently executing action mapping.- Returns:
- a new instance of StrutsLinkTool
-
-