org.codehaus.plexus.summit.pull.tools
Class TemplateLink

java.lang.Object
  extended byorg.codehaus.plexus.summit.util.UriBuilder
      extended byorg.codehaus.plexus.summit.pull.tools.TemplateLink
All Implemented Interfaces:
RequestTool
Direct Known Subclasses:
TemplateLinkWithSlash

public class TemplateLink
extends UriBuilder
implements RequestTool

A customized version of the UriBuilder to be used in Templates. This is automatically inserted into the template context by the appropriate templating service so page authors can create links in templates. Here's an example of its Velocity/WebMacro use:

$link.setPage("index.wm").addPathInfo("hello","world") This would return: http://foo.com/Turbine/template/index.wm/hello/world

Version:
$Id: TemplateLink.java 2083 2005-06-05 03:01:09Z jvanzyl $
Author:
Dave Bryson, Jon S. Stevens, Henning P. Schmiedehausen

Field Summary
private  java.lang.String target
          cache of the template name for getPage()
 
Fields inherited from class org.codehaus.plexus.summit.util.UriBuilder
ANCHOR_STATIC_PART_LENGTH, data, HTTP, HTTPS, PATH_INFO, pathInfo, QUERY_DATA, queryData, redirect, res, ROLE
 
Constructor Summary
TemplateLink()
          Default constructor

The init method must be called before use.

 
Method Summary
 java.lang.String getPage()
          Gets the template variable used by the Template Service.
 java.lang.String getURI()
          Returns the URI leaving the source intact.
 void refresh()
          Refresh the application tool.
 TemplateLink setAbsolute(boolean b)
          Set to false to skip the scheme, host, and port sections of the url.
 TemplateLink setEncodeURLOff()
          This will turn off the execution of res.encodeURL().
 TemplateLink setPage(java.lang.String t)
          Sets the template variable used by the Template Service.
 void setRunData(RunData data)
          Initialize the RequestTool with RunData from the request.
 java.lang.String toString()
          Returns the URI.
 
Methods inherited from class org.codehaus.plexus.summit.util.UriBuilder
add, add, add, addPair, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addQueryData, addQueryData, addQueryData, addQueryData, addQueryData, addQueryData, getA, getScriptName, getServerName, getServerPort, getServerScheme, hasPathInfo, hasQueryData, init, init, isEncodeUrl, isRelative, remove, removePairByName, removePathInfo, removePathInfo, removeQueryData, removeQueryData, renderPairs, renderPathInfo, renderPathInfo, renderQueryString, renderQueryString, setAction, setEncodeUrl, setRedirect, setRelative, setTarget, toString, toString, writeEncoded, writeFastEncoded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

target

private java.lang.String target
cache of the template name for getPage()

Constructor Detail

TemplateLink

public TemplateLink()
Default constructor

The init method must be called before use.

Method Detail

setEncodeURLOff

public TemplateLink setEncodeURLOff()
This will turn off the execution of res.encodeURL(). This is useful for cases where you don't want to see the session information


setPage

public TemplateLink setPage(java.lang.String t)
Sets the template variable used by the Template Service.

Parameters:
t - A String with the template name.
Returns:
A TemplateLink.

getPage

public java.lang.String getPage()
Gets the template variable used by the Template Service. It is only available after setPage() has been called.

Returns:
The template name.

setAbsolute

public TemplateLink setAbsolute(boolean b)
Set to false to skip the scheme, host, and port sections of the url. The default is to return absolute url's from the toString method.

Parameters:
b - a boolean value
Returns:
a TemplateLink value

toString

public java.lang.String toString()
Returns the URI. After rendering the URI, it clears the pathInfo and QueryString portions of the UriBuilder.

Overrides:
toString in class UriBuilder
Returns:
A String with the URI in the form http://foo.com/Turbine/template/index.wm/hello/world

getURI

public java.lang.String getURI()
Returns the URI leaving the source intact. Wraps directly to the UriBuilder.toString method of the superclass (avoiding the local toString implementation).

Returns:
A String with the URI in the form http://foo.com/Turbine/template/index.wm/hello/world

setRunData

public void setRunData(RunData data)
Description copied from interface: RequestTool
Initialize the RequestTool with RunData from the request.

Specified by:
setRunData in interface RequestTool
Parameters:
data - initialization data

refresh

public void refresh()
Description copied from interface: RequestTool
Refresh the application tool. This is necessary for development work where you probably want the tool to refresh itself if it is using configuration information that is typically cached after initialization

Specified by:
refresh in interface RequestTool