org.apache.tapestry5
Interface Link

All Known Implementing Classes:
LinkImpl

public interface Link

A link is the Tapestry representation of a URL or URI that triggers dynamic behavior. This link is in three parts: a path portion, an optional anchor, and a set of query parameters. A request for a link will ultimately be recognized by a Dispatcher.

Query parameter values are kept separate from the path portion to support encoding those values into hidden form fields (where appropriate).


Method Summary
 void addParameter(String parameterName, String value)
          Adds a parameter value.
 String getAnchor()
          Returns the link anchor.
 List<String> getParameterNames()
          Returns the names of any additional query parameters for the URI.
 String getParameterValue(String name)
          Returns the value of a specifically named query parameter, or null if no such query parameter is stored in the link.
 void setAnchor(String anchor)
          Sets the link anchor.
 String toAbsoluteURI()
          Converts the link to an absolute URI, a complete path, starting with a leading slash.
 String toRedirectURI()
          Returns the link as a redirect URI.
 String toURI()
          Returns the URI portion of the link.
 

Method Detail

getParameterNames

List<String> getParameterNames()
Returns the names of any additional query parameters for the URI. Query parameters store less regular or less often used values that can not be expressed in the path. They also are used to store, or link to, persistent state.

Returns:
list of query parameter names, is alphabetical order

getParameterValue

String getParameterValue(String name)
Returns the value of a specifically named query parameter, or null if no such query parameter is stored in the link.

Returns:
the value of the named parameter

addParameter

void addParameter(String parameterName,
                  String value)
Adds a parameter value. The value will be added, as is, to the URL. In many cases, the value should be URL encoded via URLCodec.

Parameters:
parameterName - the name of the parameter to store
value - the value to store
Throws:
IllegalArgumentException - if the link already has a parameter with the given name

toURI

String toURI()
Returns the URI portion of the link. When the link is created for a form, this will not include query parameters. This is the same value returned from toString(). In some circumstances, this may be a relative URI (relative to the current Request's URI).

Returns:
the URI, ready to be added as an element attribute

toRedirectURI

String toRedirectURI()
Returns the link as a redirect URI. The URI includes any query parameters.


getAnchor

String getAnchor()
Returns the link anchor. If this link does not have an anchor, this method returns null.

Returns:
the link anchor

setAnchor

void setAnchor(String anchor)
Sets the link anchor. Null and empty anchors will be ignored when building the link URI.

Parameters:
anchor - the link anchor

toAbsoluteURI

String toAbsoluteURI()
Converts the link to an absolute URI, a complete path, starting with a leading slash. This is necessary in many cases for client-side JavaScript that must send a request to application via XMLHttpRequest.

Returns:
the complete URI (not abbreviated relative to the current request path)


Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.