org.apache.turbine.util.template
Class TemplateLink

java.lang.Object
  |
  +--org.apache.turbine.util.DynamicURI
        |
        +--org.apache.turbine.util.template.TemplateLink
All Implemented Interfaces:
ApplicationTool
Direct Known Subclasses:
TemplateLinkWithSlash

public class TemplateLink
extends DynamicURI
implements ApplicationTool

A customized version of the DynamicURI 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,v 1.1.1.1 2001/08/16 05:10:01 jvanzyl Exp $
Author:
Dave Bryson, Jon S. Stevens, Henning P. Schmiedehausen

Fields inherited from class org.apache.turbine.util.DynamicURI
data, hasPathInfo, hasQueryData, HTTP, HTTPS, PATH_INFO, pathInfo, QUERY_DATA, queryData, redirect, reference, res, scriptName, sd, serverName, serverPort, serverScheme
 
Constructor Summary
TemplateLink()
          Default constructor
TemplateLink(RunData data)
          Constructor.
TemplateLink(ServerData data)
          Constructor.
 
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 init(java.lang.Object data)
          This will initialise a TemplateLink object that was constructed with the default constructor (ApplicationTool method).
 void refresh()
          Refresh method - does nothing
 TemplateLink setEncodeURLOff()
          This will turn off the execution of res.encodeURL() by making res == null.
 TemplateLink setPage(java.lang.String t)
          Sets the template variable used by the Template Service.
 java.lang.String toString()
          Returns the URI.
 
Methods inherited from class org.apache.turbine.util.DynamicURI
add, add, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addQueryData, addQueryData, addQueryData, addQueryData, addQueryData, addQueryData, getA, getReference, getScriptName, getServerData, getServerName, getServerPort, getServerScheme, init, init, init, remove, removePathInfo, removePathInfo, removeQueryData, removeQueryData, renderPathInfo, renderQueryString, setAction, setReference, setScreen, setScriptName, setSecure, setSecure, setServerData, setServerName, setServerPort, setServerScheme, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TemplateLink

public TemplateLink()
Default constructor

The init method must be called before use.


TemplateLink

public TemplateLink(RunData data)
Constructor.
Parameters:
data - a Turbine RunData object.

TemplateLink

public TemplateLink(ServerData data)
Constructor.
Parameters:
data - a Turbine ServerData object.
Method Detail

init

public void init(java.lang.Object data)
This will initialise a TemplateLink object that was constructed with the default constructor (ApplicationTool method).
Specified by:
init in interface ApplicationTool
Parameters:
data - assumed to be a RunData object

refresh

public void refresh()
Refresh method - does nothing
Specified by:
refresh in interface ApplicationTool

setEncodeURLOff

public TemplateLink setEncodeURLOff()
This will turn off the execution of res.encodeURL() by making res == null. This is a hack 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.

toString

public java.lang.String toString()
Returns the URI. After rendering the URI, it clears the pathInfo and QueryString portions of the DynamicURI.
Overrides:
toString in class DynamicURI
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 DynamicURI.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


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.