blob: b5198aa7be32ce10455f50d855526f238c44d107 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- $Id$ -->
<html>
<head>
<title>ActionLink</title>
<link rel="stylesheet" type="text/css" href="Tapestry.css" title="style">
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></a></td>
<td align="middle">&nbsp;</td>
<td align="right"><A href="Any.html"><IMG alt=Any src="common-images/next.png"></a></td>
<tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td colspan="3">
<table border="0" cellpadding="4" cellspacing="4" width="100%">
<tr valign="top">
<td>
<table>
<tr>
<td><font size="+2"><b>ActionLink</b></font></td>
</tr>
<tr>
<td>
<A href="../api/org/apache/tapestry/link/ActionLink.html">org.apache.tapestry.link.ActionLink</a>
</td>
</tr>
</table>
</td>
<td>
<table align="right" valign="middle" bgcolor="#c0c0c0" cellpadding="8">
<tr>
<td><A href="ActionLink.html"><font color="blue">Action Link</font></a></td>
</tr>
</table>
</td>
</tr>
<tr valign="center">
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<b>Description</b>
<br>
Creates an &lt;a&gt; hyperlink in the HTML response. If the link is
triggered, then the ActionLink retrieves its listener, and invokes
<tt>actionTriggered()</tt> on it.
<p>
See the Developers Guide
<A href="../DevelopersGuide/cycle.listeners.html">ActionLink and DirectLink listeners</a> for
a more complete description.</p>
</td>
</tr>
<tr>
<td colspan="2">
<b>See Also</b>
<br>
<A href="DirectLink.html">DirectLink</a>,
<A href="ExternalLink.html">ExternalLink</a>,
<A href="GenericLink.html">GenericLink</a>,
<a href="PageLink.html">PageLink</a>,
<a href="ServiceLink.html">ServiceLink</a>
</td>
</tr>
<tr>
<td colspan="2">
<b>Parameters</b>
<br>
<table border="1" cellpadding="4" cellspacing="4" class="parameters">
<tr>
<th>Name</th>
<th>Type</th>
<th>Direction</th>
<th>Required</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<td>listener</td>
<td>
<A href="../api/org/apache/tapestry/IActionListener.html"><tt>IActionListener</tt></a>
</td>
<td>in</td>
<td>yes</td>
<td>&nbsp;</td>
<td>Specifies an object that is notified when the link is clicked,
which is typically a listener method of its container
(for example, <tt>listeners.<i>method</i></tt>).</td>
</tr>
<tr>
<td>disabled</td>
<td>boolean</td>
<td>in</td>
<td>no</td>
<td>false</td>
<td>Controls whether the link is produced. If disabled, the portion of the
template the link surrounds is still rendered, but not the link itself.
</td>
</tr>
<tr>
<td>stateful</td>
<td>boolean</td>
<td>in</td>
<td>no</td>
<td>true</td>
<td>
If true (the default), then the component requires an active (i.e., non-new)
<tt>HttpSession</tt> when triggered. Failing that, it throws a
<A href="../api/org/apache/tapestry/StaleLinkException.html"><tt>StaleLinkException</tt></a>.
If false, then no check is necessary. The
latter works well with links that encode all necessary state inside the URL
itself.
</td>
</tr>
<tr>
<td>anchor</td>
<td>String</td>
<td>in</td>
<td>no</td>
<td>&nbsp;</td>
<td>
The name of an anchor or element to link to. The final URL will have '#'
and the anchor appended to it.
</td>
</tr>
<tr>
<td>renderer</td>
<td><a href="../api/org/apache/tapestry/link/ILinkRenderer.html">ILinkRenderer</a></td>
<td>in</td>
<td>no</td>
<td>&nbsp;</td>
<td>
The object which will actually render the link.
</td>
</tr>
</table>
<P>
Body: <STRONG>rendered</STRONG><BR>
Informal parameters: <STRONG>allowed</STRONG><br>
Reserved parameters: "href"
</P>
</td>
</tr>
<tr>
<td colspan="2">
<b>Examples</b>
<p>
<p>
In this example the ActionLink component enables users to select a Customer
from the Customer List table.
<p>
<table class="examples" cellspacing="6">
<tr align="left">
<th>ID</th>
<th>&nbsp;</th>
<th>Name</th>
<th>&nbsp;</th>
<th>Level</th>
</tr>
<tr>
<td colspan="5"><hr></td>
</tr>
<tr>
<td>10276</td>
<td>&nbsp;</td>
<td><a href="ActionLink.html" style="{color:blue;}">Ms Sophie L. Jamies</a></td>
<td>&nbsp;</td>
<td>Platinum</td>
</tr>
<tr>
<td>10539</td>
<td>&nbsp;</td>
<td><a href="ActionLink.html" style="{color:blue;}">Mr Albert H. Davies</a></td>
<td>&nbsp;</td>
<td>Gold</td>
</tr>
<tr>
<td>10552</td>
<td>&nbsp;</td>
<td><a href="ActionLink.html" style="{color:blue;}">Mrs Jan S. Flawson</a></td>
<td>&nbsp;</td>
<td>Gold</td>
</tr>
<tr>
<td>10863</td>
<td>&nbsp;</td>
<td><a href="ActionLink.html" style="{color:blue;}">Mr Robert J. Hassel</a></td>
<td>&nbsp;</td>
<td>Silver</td>
</tr>
</table>
<pre>
&lt;table cellspacing="6"&gt;
&lt;tr&gt;
&lt;td&gt;ID&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Level&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="5"&gt;&lt;hr&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr jwcid="@<a href="Foreach.html">Foreach</a>" source=&quot;ognl:customerList&quot; value=&quot;ognl:customer&quot; element=&quot;tr&quot;&gt;
&lt;td&gt;&lt;span jwcid="@<a href="Insert.html">Insert</a>" value="ognl:customer.id"/&gt;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;span jwcid="<span class="jwcid">@<a href="ActionLink.html">ActionLink</a></span>" listener=&quot;ognl:listeners.customerSelectAction&quot;&gt; &lt;span jwcid="@<a href="Insert.html">Insert</a>" value="ognl:customer.fullName"/&gt; &lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;span jwcid="@<a href="Insert.html">Insert</a>" value="ognl:customer.memberLevel"/&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;property-specification name=&quot;customerList&quot; type=&quot;java.util.List&quot; persistent=&quot;yes&quot;/&gt;<br>&lt;property-specification name=&quot;customer&quot; type=&quot;Customer&quot;/&gt;<br>
public abstract class SalesPage extends BasePage {
public abstract List getCustomerList();
public abstract List setCustomerList(List value);
public abstract Customer getCustomer();
public void customerSelectAction(IRequestCycle cycle) {
Customer customer = getCustomer();
// Do something with customer
}
}
public class Customer implements Serializable {
private Integer id;
private String fullName;
private String memberLevel;
public Customer(Integer id, String fullName, String memberLevel) {
this.id = id;
this.fullName = fullName;
this.memberLevel = memberLevel;
}
public Integer getId() { return id; }
public String getFullName() { return fullName; }
public String getMemberLevel() { return memberLevel; }
}
</pre>
</td>
</tr></table>
</td></tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td align="left"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></a></td>
<td align="middle">&nbsp;</td>
<td align="right"><A href="Any.html"><IMG alt=Any src="common-images/next.png"></a></td>
</tr>
</table>
</body>
</html>