blob: 4b3f7d364d18b6ca92ab6827fef60547dead5a83 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 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>Determining the Page Class</title>
</properties>
<body>
<section name="Determining the Page Class">
<p>
When it comes time for Tapestry to instantiate a page, it must identify the Java
class to instantiate.
</p>
<p>
Tapestry pages implement the
<a href="../apidocs/org/apache/tapestry/IPage.html">IPage</a>
interface. Because this is a large interface, you will typically extends the
<a href="../apidocs/org/apache/tapestry/html/BasePage.html">
BasePage
</a>
base class (for HTML pages).
</p>
<p>
Typically, you will identify the page class within the page's specification, using
the
<a href="spec.html#spec.page-specification">&lt;page-specification&gt;</a>
element's class attribute.
</p>
<p>
In many cases, however, the page specification is optional. Alternately, the class
attribute may be omitted from the page specification. Tapestry takes the following
steps to find the class for a page:
</p>
<ul>
<li>As indicated in the page specification</li>
<li>
By searching the packages listed in the application specification (more below)
</li>
<li>
The application specification's org.apache.tapestry.default-page-class property
</li>
<li>The global property org.apache.tapestry.default-page-class</li>
</ul>
<p>
The most useful of these is the second option, to search. For this step, Tapestry
looks in the application specification for the
org.apache.tapestry.page-class-packages
<a href="spec.html#spec.meta">&lt;meta&gt;</a>
property. This is a comma-seperated list of package names to search. The list of
packages is optional, and the default Java package is searched last.
</p>
<p>
Also, for this search, the page name is converted into a partial class name. For
pages inside folders, the folder names are part of the package name, so page name
<code>admin/EditUser</code>
will be become
<code>admin.EditUser</code>
.
</p>
<p>
So, if the prefix list is
<code>org.example.pages</code>
, then Tapestry will search for
<code>org.example.pages.admin.EditUser</code>
, then
<code>admin.EditUser</code>
(that is, in the default package).
</p>
<p>
Only if those searches fail to locate a class does Tapestry continue to the next
steps, using default page class names in the application specification and beyond.
</p>
<span class="info">
<strong>Note:</strong>
<p>
These steps are specified in the
<a
href="../tapestry-framework/hivedoc/config/tapestry.page.PageClassProviderChain.html">
tapestry.page.PageClassProviderChain
</a>
configuration point.
</p>
</span>
<p>
For simplicity, we described the search for application pages. For pages within a
library, the process is the same, but it is the library's specification which is
searched for the list of packages, and later, for the default page class name.
</p>
<subsection name="Component Classes">
<p>
A similar search occurs for components (again, with the express desire that the
class attribute of the
<a href="spec.html#spec.component-specification">
&lt;component-specification&gt;
</a>
<em>not</em>
be used).
</p>
<ul>
<li>As defined by the component specification</li>
<li>
In any package defined by the containing namespace's
org.apache.tapestry.component-class-packages meta data property (if any)
</li>
<li>In the default package</li>
<li>
<a
href="../apidocs/org/apache/tapestry/BaseComponent.html">
BaseComponent
</a>
is the final default
</li>
</ul>
<span class="info">
<strong>Note:</strong>
<p>
These steps are specified in the
<a
href="../tapestry-framework/hivedoc/config/tapestry.page.ComponentClassProviderChain.html">
tapestry.page.ComponentClassProviderChain
</a>
configuration point.
</p>
</span>
</subsection>
</section>
</body>
</document>