Summary
Definitions
Overview
Illustration 1
Page Template
Page Specification
-Page Class
Application Specification
web.xml
Illustration 2
Illustration 3
The Framework - a flyby
Conclusion
Biography
Resources
|
Page Class
package demo;
import org.apache.tapestry.html.BasePage;
public class Home extends BasePage {
private String userName = "Jack";
public String getUserName() {
return this.userName;
}
}
Listing 3. Home.java
The last piece of our Page component is the component class –
demo.Home . The component class is a JavaBeans class that
typically houses the properties that supply data to the contained
components. In other words, these properties typically act as foreign
objects that will be bound to the parameters of the contained
components. In our example, the Page component class
(demo.Home ) houses the userName property that
supplies the name Jack to user , the contained
Insert JWC, via the getUserName method. Note
that the contained Insert JWC does not care where the
name comes from. For all it cares, the getUserName method
can get the name from a directory service, a database or a legacy
system.
In addition to providing data, the component class also provides the
behavior of the component via listener and lifecycle methods. The
framework provides a base component class each for JWC
(BaseComponent ) and Page (BasePage )
components that can be extended by applications. These base component
classes provide the default behavior for the necessary listener and
lifecycle methods thus keeping the extended classes short and simple
like our example Page component class (demo.Home ).
The naming convention for the component class is the name of the
component itself. And thus our component class is named
Home . Component classes are typically placed in the
WEB-INF/classes folder under the context of the web application
like any other Java web application. So, if Welcome is the
context of our Welcome application, Home.class will
typically to be placed under
webapps/Welcome/WEB-INF/classes .
|