Font size:
ActionLink
Creates an <a> hyperlink in the HTML response. If the link is triggered, then the ActionLink retrieves its listener, and invokes actionTriggered() on it.
See the Developers Guide ActionLink and DirectLink listeners for a more complete description.
See also: DirectLink, ExternalLink, GenericLink, PageLink, ServiceLink
Parameters
Name | Type | Direction | Required | Default | Description |
---|---|---|---|---|---|
listener | IActionListener | in | yes | Specifies an object that is notified when the link is clicked, which is typically a listener method of its container (for example, listeners.method). | |
disabled | boolean | in | no | false | Controls whether the link is produced. If disabled, the portion of the template the link surrounds is still rendered, but not the link itself. |
stateful | boolean | in | no | true | If true (the default), then the component requires an active (i.e., non-new) HttpSession when triggered. Failing that, it throws a StaleLinkException. If false, then no check is necessary. The latter works well with links that encode all necessary state inside the URL itself. |
anchor | String | in | no | The name of an anchor or element to link to. The final URL will have '#' and the anchor appended to it. | |
renderer | ILinkRenderer | in | no | The object which will actually render the link. |
Body: rendered
Informal parameters: allowed
Reserved parameters: href
Examples
In this example the ActionLink component enables users to select a Customer from the Customer List table.
<table class="examples" cellspacing="6"> <tr align="left"> <th>ID</th> <th> </th> <th>Name</th> <th> </th> <th>Level</th> </tr> <tr> <td colspan="5"><hr></td> </tr> <tr> <td>10276</td> <td> </td> <td><a href="ActionLink.html" style="{color:blue;}">Ms Sophie L. Jamies</a></td> <td> </td> <td>Platinum</td> </tr> <tr> <td>10539</td> <td> </td> <td><a href="ActionLink.html" style="{color:blue;}">Mr Albert H. Davies</a></td> <td> </td> <td>Gold</td> </tr> <tr> <td>10552</td> <td> </td> <td><a href="ActionLink.html" style="{color:blue;}">Mrs Jan S. Flawson</a></td> <td> </td> <td>Gold</td> </tr> <tr> <td>10863</td> <td> </td> <td><a href="ActionLink.html" style="{color:blue;}">Mr Robert J. Hassel</a></td> <td> </td> <td>Silver</td> </tr> </table>
HTML template
<table cellspacing="6"> <tr> <td>ID</td> <td> </td> <td>Name</td> <td> </td> <td>Level</td> </tr> <tr> <td colspan="5"><hr></td> </tr> <tr jwcid="@Foreach" source="ognl:customerList" value="ognl:customer" element="tr"> <td><span jwcid="@Insert" value="ognl:customer.id"/></td> <td> </td> <td><span jwcid="@ActionLink" listener="listener:customerSelectAction"> <span jwcid="@Insert" value="ognl:customer.fullName"/> </span></td> <td> </td> <td><span jwcid="@Insert" value="ognl:customer.memberLevel"/></td> </tr> </table>
Page specification
<property-specification name="customerList" type="java.util.List" persistent="yes"/> <property-specification name="customer" type="Customer"/>
Java sources
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; } }