Creates a HTML <a> hyperlink to another page within the application. The Page component uses the PageService to construct the anchor's "href" URL.
See also: org.apache.tapestry.link.PageLink , DirectLink , ExternalLink , GenericLink , Rollover , ServiceLink
Name | Type | Direction | Required | Default | Description |
---|---|---|---|---|---|
page | String | in | yes | The name of an application page to link to. | |
namespace | INamespace | in | no | If specified, the namespace's prefix is prefixed (with a colon) to the page name. This is primarily used when pages (or components) in a namespace need to create links to other pages inside the same namespace (this is only a concern for developers of component libraries, not developers of applications). | |
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. |
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. | |
scheme | String | in | no | The required scheme ("http" or "https", typically) for the URL. This will force the creation of an absolute URL when the current request's scheme does not match the value for this parameter. This is most often used to switch to "https" for secure portions of an application (such as a login page), before switching back to standard "http" for the majority of an application. | |
port | Integer | in | no | The required port (80, 443, 8080. 8443, typically) for the URL. This will force the creation of an absolute URL when the current request's scheme does not match the value for this parameter. This is most often used in conjunction with scheme to switch to "https:443"/"https:8443" for secure portions of an application (such as a login page), before switching back to standard "http:80"/"http:80" for the majority of an application. | |
target | String | in | no | ||
renderer | ILinkRenderer | in | no | The object which will actually render the link. |
Body: allowed
Informal parameters: allowed
Reserved parameters: href
There are two PageLink components in our Home page: Page1 and Page2.
The Home.html:
... <a jwcid="@PageLink" page="Page1">go to Page1</a> <p> </p> <a jwcid="page2">go to Page2</a> ...
The Home.page:
... <page-specification> ... <component id="page2" type="PageLink"> <binding name="page" value="literal:Page2"/> </component> ... </page-specification>
Note: in the Home.page file, we use "literal" prefix when binding value of the "page" parameter of "page2" component, because the default prefix in the specification file is "ognl".
Another example:
This example uses the PageLink component to create a navigation menu bar across the top of the page. If the user is not authenticated, in their Visit object, all the navigation bar links are disabled.
Typically you would create an navigation menu component, using the RenderBody component. This navigation menu component would then be included as the first element in all the application's pages.
the html file:
<!-- Navigation Bar --> <table bgcolor="navy" cellpadding="8" cellspacing="6" width="100%"> <tr jwcid="@Foreach" source="ognl:engine@NAVIGATION_PAGES" value="ognl:navigationPage" element="tr"> <td><font color="white"><b><span jwcid="@PageLink" page="ognl:navigationPage" disabled="ognl:! visit.authenticated"/></b></font></td> </tr> </table>
the application specification file:
... <application name="PageLink Examples"> <meta key="org.apache.tapestry.engine-class" value="MailEngine"/> ... </application>
the page specification file:
... <page-specification class="MailPage"> <property name="navigationPage"/> ... </page-specification>
the java class files:
public abstract class MailPage extends BasePage { public abstract String getNavigationPage(); } public class Visit implements Serializable { private boolean authenticated; public boolean isAuthenticated() { return authenticated; } public void setAuthenticated(boolean value) { authenticated = value; } } public class MailEngine extends SimpleEngine implements Serializable { public static final String[] NAVIGATION_PAGES = { "Home", "Inbox", "Sent", "Compose", "Contacts", "Options", "Help", "Logout" }; }