| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Copyright 2004, 2005 The Apache Software Foundation |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <document> |
| <properties> |
| <title>PageLink</title> |
| </properties> |
| <body> |
| |
| <section name="PageLink"> |
| |
| <p> |
| Creates a HTML <code><a></code> hyperlink to another page within the application. The Page |
| component uses the PageService to construct the anchor's "href" URL. |
| </p> |
| |
| <p> |
| <strong> |
| See also: |
| <a href="../../apidocs/org/apache/tapestry/link/PageLink.html"> |
| org.apache.tapestry.link.PageLink |
| </a> |
| , |
| <a href="directlink.html">DirectLink</a> |
| , |
| <a href="externallink.html">ExternalLink</a> |
| , |
| <a href="genericlink.html">GenericLink</a> |
| , |
| <a href="rollover.html">Rollover</a> |
| , |
| <a href="servicelink.html">ServiceLink</a> |
| </strong> |
| |
| </p> |
| |
| <section name="Parameters"> |
| <table> |
| <tr> |
| <th>Name</th> |
| <th>Type</th> |
| <th>Required</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>page</td> |
| <td>String</td> |
| <td>yes</td> |
| <td></td> |
| <td>The name of an application page to link to.</td> |
| </tr> |
| <tr> |
| <td>namespace</td> |
| <td> |
| <a href="../../apidocs/org/apache/tapestry/INamespace.html"> |
| INamespace |
| </a> |
| </td> |
| <td>no</td> |
| <td></td> |
| <td> |
| 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). |
| </td> |
| </tr> |
| <tr> |
| <td>disabled</td> |
| <td>boolean</td> |
| <td>no</td> |
| <td>false</td> |
| <td> |
| Controls whether the link is produced. If disabled, the portion of the |
| template the link surrounds is still rendered, but not the link itself. |
| </td> |
| </tr> |
| <tr> |
| <td>anchor</td> |
| <td>String</td> |
| <td>no</td> |
| <td></td> |
| <td> |
| The name of an anchor or element to link to. The final URL will have '#' |
| and the anchor appended to it. |
| </td> |
| </tr> |
| |
| <tr> |
| <td>scheme</td> |
| <td>String</td> |
| <td>no</td> |
| <td></td> |
| <td> |
| 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. |
| </td> |
| </tr> |
| |
| <tr> |
| <td>port</td> |
| <td>Integer</td> |
| <td>no</td> |
| <td></td> |
| <td> |
| 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. |
| </td> |
| </tr> |
| <tr> |
| <td>target</td> |
| |
| <td>String</td> |
| <td>no</td> |
| <td /> |
| <td> |
| The name of the html target for this link, this is just the normal html attribute that will |
| control where the response generated from this link will go. (Usually used in frames) |
| </td> |
| </tr> |
| <tr> |
| <td>renderer</td> |
| |
| <td> |
| <a |
| href="../../apidocs/org/apache/tapestry/link/ILinkRenderer.html"> |
| ILinkRenderer |
| </a> |
| </td> |
| <td>no</td> |
| <td></td> |
| <td>The object which will actually render the link.</td> |
| </tr> |
| </table> |
| |
| |
| <p> |
| Body: |
| <strong>allowed</strong> |
| </p> |
| |
| <p> |
| Informal parameters: |
| <strong>allowed</strong> |
| </p> |
| |
| <p> |
| Reserved parameters: |
| <em>href</em> |
| |
| </p> |
| |
| </section> |
| |
| <section name="Examples"> |
| |
| |
| <p>There are two PageLink components in our Home page: Page1 and Page2.</p> |
| |
| <p>The Home.html:</p> |
| <source xml:space="preserve"><![CDATA[ |
| ... |
| <a jwcid="@PageLink" page="Page1">go to Page1</a> |
| <p> </p> |
| <a jwcid="page2">go to Page2</a> |
| ... |
| |
| ]]></source> |
| |
| <p>The Home.page:</p> |
| |
| <source xml:space="preserve"><![CDATA[ |
| ... |
| <page-specification> |
| ... |
| <component id="page2" type="PageLink"> |
| <binding name="page" value="literal:Page2"/> |
| </component> |
| ... |
| </page-specification> |
| |
| ]]></source> |
| |
| <p> |
| 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". |
| </p> |
| |
| |
| <p/> |
| <p> |
| <strong>Another example:</strong> |
| </p> |
| <p> |
| |
| 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. |
| </p> |
| <p> |
| 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. |
| </p> |
| |
| <p>the html file:</p> |
| <source xml:space="preserve"><![CDATA[ |
| <!-- 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><a jwcid="@PageLink" page="ognl:navigationPage" |
| disabled="ognl:! visit.authenticated">Link</a></b></font></td> |
| </tr> |
| </table> |
| |
| ]]></source> |
| |
| <p>the application specification file:</p> |
| |
| <source xml:space="preserve"><![CDATA[ |
| ... |
| <application name="PageLink Examples"> |
| <meta key="org.apache.tapestry.engine-class" value="MailEngine"/> |
| ... |
| </application> |
| |
| ]]></source> |
| |
| <p>the page specification file:</p> |
| <source xml:space="preserve"><![CDATA[ |
| ... |
| <page-specification class="MailPage"> |
| <property name="navigationPage"/> |
| ... |
| </page-specification> |
| |
| ]]></source> |
| |
| <p>the java class files:</p> |
| |
| <source xml:space="preserve"> |
| 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" }; |
| } |
| |
| </source> |
| |
| </section> |
| |
| </section> |
| |
| </body> |
| </document> |