org.apache.tapestry5.corelib.components

## Class PageLink

- java.lang.Object
- - org.apache.tapestry5.corelib.base.AbstractLink
  - - org.apache.tapestry5.corelib.components.PageLink

- All Implemented Interfaces:
    ClientElement

      public class PageLink
      extends AbstractLink

  Generates a render request link to some other page in the application. If an activation context is supplied (as the context parameter), then the context values will be encoded into the URL. If no context is supplied, then the target page itself will supply the context via a passivate event.

  Pages are not required to have an activation context. When a page does have an activation context, the value typically represents the identity of some object displayed or otherwise manipulated by the page.

  Component Parameters
  Name | Type | Flags | Default | Default Prefix
  --- | --- | --- | --- | ---
  anchor | String |  |  | literal
  An anchor value to append to the generated URL (the hash separator will be added automatically).
  context | Object |  |  | prop
  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.
  disabled | boolean |  | false | prop
  If true, then then no link element is rendered (and no informal parameters as well). The body is, however, still rendered.
  page | Object | Required, Not Null |  | literal
  The page to link to. If a `String`, as usual, it should be the page logical name. If it's a `Class` instance, it's treated as the target page. If it's not a `String` nor an `Class`, the target page will be the result of calling `page.getClass()`. Notice you'll need to use the `prop` binding when passing a value which isn't a `String`.
  parameters | java.util.Map | Not Null, Since 5.3 |  | prop
  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.

  ### Related Components

    - ActionLink
    - EventLink

  ### Examples

    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:

    ### UserList.html (partial)

                <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>

    ### ViewUser.java

    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);
            }
        }

    ### ViewUser.tml

        <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.

- - ### Field Summary

    - ### Fields inherited from class org.apache.tapestry5.corelib.base.AbstractLink

      `resources`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PageLink()`

  - ### Method Summary

    - ### Methods inherited from class org.apache.tapestry5.corelib.base.AbstractLink

      `addParameters, getClientId, getLink, isDisabled, writeLink`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PageLink

          public PageLink()

${project.version} - Copyright © 2003-2014 The Apache Software Foundation.