Table of Contents
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.
There are two basic types of components: those that use an HTML template, and those that don't.
Nearly all of the base components provided with the Tapestry framework don't use templates. They inherit from the class AbstractComponent. Such components must implement the render() method.
Components that use templates inherit from a subclass of AbstractComponent: BaseComponent. They should leave the render() method alone.
In some cases, a new component can be written just by combining existing components (this often involves using inherited bindings). Such a codeless component will consist of just a specification and an HTML template and will use the BaseComponent class without subclassing. This is even more possible when using helper beans.