public class PageLink extends AbstractLink
Component Parameters | ||||||
---|---|---|---|---|---|---|
Name | Description | Type | Flags | Default | Default Prefix | Since |
anchor | An anchor value to append to the generated URL (the hash separator will be added automatically). | String | literal | |||
context | If provided, this is the activation context for the target page (the information will be encoded into the URL). If not provided, then the target page will provide its own activation context. | Object | prop | |||
disabled | If true, then then no link element is rendered (and no informal parameters as well). The body is, however, still rendered. | boolean | false | prop | ||
page | The logical name of the page to link to. | String | Required, Not Null | literal | ||
parameters | If specified, the parameters are added to the link as query parameters in key=value fashion. Values will be coerced to string using value encoder; keys should be Strings. | java. | Not Null | prop | 5.3 |
We're continuing with the example introduced in the Grid examples.
The UserList page renders a series of page links, passing the user id as the context:
<t:grid source="users" row="user" model="model"> <p:lastnamecell> <t:pagelink page="user/view" context="user.id">${user.lastname}</t:pagelink> </p:lastnamecell> </t:grid>
The ViewUser page is responsible for converting that user id back into a User instance, by providing an event handler method for the "activate" event.
public class ViewUser { private User user; @Inject private UserDAO userDAO; public User getUser() { return user; } void onActivate(long userId) { user = userDAO.findById(userId); } }
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> <body> <h1>View User</h1> <t:beandisplay object="user"/> </body> </html>
Rendering out the User object, using a BeanDisplay component, is easy, and the template doesn't have to know or care about the page activation context; it just reads the user property.
Constructor and Description |
---|
PageLink() |
addParameters, getClientId, getLink, isDisabled, writeLink
public PageLink()
Copyright © 2003-2012 The Apache Software Foundation.