| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <!-- $Id$ --> |
| <html> |
| <head> |
| <title>DirectLink</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="Delegator.html"><IMG alt=Delegator src="common-images/prev.png"></A></td> |
| <td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></A></td> |
| <td align="right"><A href="ExceptionDisplay.html"><IMG alt=ExceptionDisplay 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>DirectLink</b></font></td> |
| </tr> |
| <tr> |
| <td> |
| <A href="../api/org/apache/tapestry/link/DirectLink.html"> |
| org.apache.tapestry.link.DirectLink</A> |
| </td> |
| </tr> |
| </table> |
| </td> |
| <td> |
| <table align="right" valign="middle" bgcolor="#c0c0c0" cellpadding="8"> |
| <tr> |
| <td><A href="DirectLink.html"><font color="blue">Direct Link</font></A></td> |
| </tr> |
| </table> |
| </td> |
| </tr> |
| |
| <tr valign="center"> |
| <td colspan="2"> </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>Description</b> |
| <br> |
| Creates a <a> hyperlink that notifies the component when the link is |
| triggered. The link includes some context-specific data that is made available |
| to the component's listener. This is used in cases where the |
| <a href="ActionLink.html">ActionLink</a> component can't be used (or is too inefficient). |
| <p> |
| See the Developers Guide <A href="../DevelopersGuide/cycle.listeners.html"> |
| ActionLink and DirectLink listeners</A> for a more complete description.</p> |
| <P>Prior to release 2.2, this component was named |
| <STRONG>Direct</STRONG>.</P> |
| |
| </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>See Also</b> |
| <br> |
| <a href="ActionLink.html">ActionLink</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> </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>parameters</td> |
| <td>Object or<br> |
| Object[] or<br> |
| <a href="http://java.sun.com/products/jdk/1.2/docs/api/java/util/List.html"> |
| <tt>List</tt></a> |
| </td> |
| <td>in</td> |
| <td>no</td> |
| <td> </td> |
| <td> |
| An array of objects to be encoded into the URL. These parameters will be |
| decoded when the link is triggered. |
| <p> |
| In a web application built onto of Enterprise JavaBeans, the context is |
| often the primary key of some Entity bean; typically such keys are Strings |
| or Integers. |
| <p> |
| A listener method can retrieve the parameters using |
| <A href="../api/org/apache/tapestry/IRequestCycle.html#getServiceParameters()"> |
| <tt>IRequestCycle.getServiceParameters()</tt></A>. |
| <p> |
| Prior to release 2.2, the parameters were always type String. They may now |
| be of any type; type will be maintained when the parameters are later |
| retrieved by a listener. See |
| <A href="../api/org/apache/tapestry/util/io/DataSqueezer.html"><tt>DataSqueezer</tt></A> for more details.</p> |
| |
| </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"><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> </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> </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> |
| In this example the DirectLink component enables users to select or delete |
| Customers from a Customer List table. |
| <p> |
| |
| <table class="examples" cellspacing="6"> |
| <tr align="left"> |
| <th>ID</th> |
| <th> </th> |
| <th>Name</th> |
| <th> </th> |
| <th>Level</th> |
| <th> </th> |
| </tr> |
| <tr> |
| <td colspan="6"><hr></td> |
| </tr> |
| <tr> |
| <td>10276</td> |
| <td> </td> |
| <td><a href="DirectLink.html" style="{color:blue;}">Ms Sophie L. Jamies</a></td> |
| <td> </td> |
| <td>Platinum</td> |
| <td><a href="DirectLink.html" style="{color:blue;}"><img src="images/delete.gif" alt="Delete"></a></td> |
| </tr> |
| <tr> |
| <td>10539</td> |
| <td> </td> |
| <td><a href="DirectLink.html" style="{color:blue;}">Mr Albert H. Davies</a></td> |
| <td> </td> |
| <td>Gold</td> |
| <td><a href="DirectLink.html" style="{color:blue;}"><img src="images/delete.gif" alt="Delete"></a></td> |
| </tr> |
| <tr> |
| <td>10552</td> |
| <td> </td> |
| <td><a href="DirectLink.html" style="{color:blue;}">Mrs Jan S. Flawson</a></td> |
| <td> </td> |
| <td>Gold</td> |
| <td><a href="DirectLink.html" style="{color:blue;}"><img src="images/delete.gif" alt="Delete"></a></td> |
| </tr> |
| <tr> |
| <td>10863</td> |
| <td> </td> |
| <td><a href="DirectLink.html" style="{color:blue;}">Mr Robert J. Hassel</a></td> |
| <td> </td> |
| <td>Silver</td> |
| <td><a href="DirectLink.html" style="{color:blue;}"><img src="images/delete.gif" alt="Delete"></a></td> |
| </tr> |
| </table> |
| |
| <pre> |
| <table cellspacing="6"> |
| <tr> |
| <td>ID</td> |
| <td>&nbsp;</td> |
| <td>Name</td> |
| <td>&nbsp;</td> |
| <td>Level</td> |
| <td>&nbsp;</td> |
| </tr> |
| <tr> |
| <td colspan="6"><hr></td> |
| </tr> |
| <tr jwcid="@<a href="Foreach.html">Foreach</a>" source="ognl:visit.customerList" value="ognl:customer" element="tr"> |
| <td><span jwcid="@<a href="Insert.html">Insert</a>" value="ognl:customer.id"/></td> |
| <td>&nbsp;</td> |
| <td><a jwcid="<span class="jwcid">@<a href="DirectLink.html">DirectLink</a></span>" listener="ognl:listeners.customerSelectAction" parameters="ognl:customer.id"> <span jwcid="@<a href="Insert.html">Insert</a>" value="ognl:customer.fullName"/> </a></td> |
| <td>&nbsp;</td> |
| <td><span jwcid="@<a href="Insert.html">Insert</a>" value="ognl:customer.memberLevel"/></td> |
| <td> |
| <a jwcid="<span class="jwcid">@<a href="DirectLink.html">DirectLink</a></span>" listener="ognl:listeners.customerDeleteAction" parameters="ognl:customer.id" onclick="return window.confirm('Are you sure you want remove this customer?');"> |
| <img jwcid="@<a href="Image.html">Image</a>" image="ognl:assets.deleteImage" alt="Delete"/> |
| </a> |
| </td> |
| </tr> |
| </table> |
| |
| |
| <property-specification name="customer" type="com.mycorp.Customer"/><br><private-asset name="deleteImage" resource-path="/com/mycorp/delete.gif"/> |
| |
| |
| package com.mycorp; |
| |
| public abstract class SalesPage extends BasePage { |
| public void customerSelectAction(IRequestCycle cycle) { |
| Visit visit = (Visit) getVisit(); |
| Object[] parameters = cycle.getServiceParameters(); |
| Customer customer = visit.findCustomerByPrimaryKey((Integer) parameters[0]); |
| // Perform some action with the selected customer. |
| .. |
| } |
| |
| public void customerDeleteAction(IRequestCycle cycle) { |
| Visit visit = (Visit) getVisit(); |
| Object[] parameters = cycle.getServiceParameters(); |
| Customer customer = visit.findCustomerByPrimaryKey((Integer) parameters[0]); |
| visit.deleteCustomer(customer); |
| } |
| } |
| |
| public class Visit() implements Serializable { |
| |
| public List getCustomerList() { |
| List customerList = new ArrayList(); |
| // Perform a database query retrieving the list of customers. |
| .. |
| return customerList; |
| } |
| |
| public Customer findCustomerByPrimaryKey(Integer id) { |
| Customer customer = null; |
| // Retrieve the customer from the database with given the customer ID. |
| .. |
| return customer; |
| } |
| |
| public void deleteCustomer(Customer customer) { |
| // Delete customer from the database. |
| .. |
| } |
| } |
| |
| 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="Delegator.html"><IMG alt=Delegator src="common-images/prev.png"></A></td> |
| <td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></A></td> |
| <td align="right"><A href="ExceptionDisplay.html"><IMG alt=ExceptionDisplay src="common-images/next.png"></A></td> |
| </tr> |
| </table> |
| |
| </body> |
| </html> |