org.apache.wicket.markup.html.link
Interface IPageLink

All Superinterfaces:
IClusterable, Serializable

public interface IPageLink
extends IClusterable

Interface that is used to implement delayed page linking. The getPage() method returns an instance of Page when a link is actually clicked (thus avoiding the need to create a destination Page object for every link on a given Page in advance). The getPageIdentity() method returns the subclass of Page that getPage() will return if and when it is called.

This way of arranging things is useful in determining whether a link links to a given page, which is in turn useful for deciding how to display the link (because links in a navigation which link to a page itself are not useful and generally should instead indicate where the user is in the navigation).

To understand how getPageIdentity() is used in this way, take a look at the Link.linksTo() method and its override in PageLink. Also, see the documentation for getPageIdentity() below.

Author:
Jonathan Locke
See Also:
Link.linksTo(Page)

Method Summary
 Page getPage()
          Gets the page to go to.
 Class<? extends Page> getPageIdentity()
          Gets the class of the destination page, which serves as a form of identity that can be used to determine if a link is on the same Page that it links to.
 

Method Detail

getPage

Page getPage()
Gets the page to go to.

Returns:
The page to go to.

getPageIdentity

Class<? extends Page> getPageIdentity()
Gets the class of the destination page, which serves as a form of identity that can be used to determine if a link is on the same Page that it links to. When Pages are parameterized, the Link.linksTo() method should be overridden instead.

A page's identity is important because links which are on the same page that they link to often need to be displayed in a different way to indicate that they are 'disabled' and don't go anywhere. Links can be manually disabled by calling Link.setDisabled(). Links which have setAutoEnable(true) will automatically enable or disable themselves depending on whether or not Link.linksTo() returns true. The default implementation of PageLink.linksTo() therefore looks like this:

 private final IPageLink pageLink;
 
 public boolean linksTo(final Page page)
 {
        return page.getClass() == pageLink.getPageIdentity();
 }
 

Returns:
The class of page linked to, as a form of identity
See Also:
Link.linksTo(Page)


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.