Chapter 9. Designing new components

Table of Contents

Choosing a base class
Parameters and Bindings
Persistent Component State
Component Assets

Creating new components using Tapestry is designed to be quite simple.

Components are typically created through aggregation, that is, by combining existing components using an HTML template and specification.

You will almost always want to define a short alias for your new component in the application specification. This insulates developers from minor name changes to the component specification, such as moving the component to a different Java package.

Like pages, components should reset their state back to default values when the page they are contained within is returned to the pool.

Most components do not have any state. A component which does should implement the PageDetachListener interface, and implement the pageDetached() method.

The pageDetached() method is invoked from the page's detatch() method, which is invoked at the very end of the request cycle, just before the page is returned to the page pool.