Chapter 1. Introduction

Tapestry is a component-oriented Java web application framework.

Web page as a jigsaw puzzle. 

Building a web page in Tapestry is somewhat like putting together a jigsaw puzzle like shown in the figure above! The pieces of the puzzle are the analogous couterparts of components in Tapestry. The components themselves can be a puzzle and be put together by arranging other components together in place. And there is no limit to this game! In a manner of speaking this hierarchy is similar to that of a parent and a child or more appropriately a container and a contained. Everything here is a component, in fact technically a web page is also a component, a specialized top level component in the hierarchy. So, what is a component?

Component overview. 

Structurally, a component is simply a template (HTML, WML, whatever), a specification (XML) and a JavaBeans class together as a whole. Conceptually, a component is a reusable black box, when given some input, adds value to the container; in this context the value is typically web interface like a text field or a web page for example. Like the pieces of the puzzle, Tapestry components can simply be dropped into a container (a page or another component) that provides the right environment. Every component in Tapestry has a unique name and together they are generically called Java Web Components (JWCs).

The template is simply markup text like HTML! Parts of this markup text can impart special meaning to Tapestry. These parts are called template or placeholder tags. The placeholder tags are identified by the presence of the "jwcid" attribute. The placeholder tags act as a placeholder for the dynamic portions of the page that will be filled in by components.

The specification is the definition of the component. It identifies the template and the JavaBeans class for the component. In addition, it primarily identifies the components (the contained components) that will be plugged in place of the placeholder tags in the template when the page is rendered, and defines what goes into these components and what comes out. The specification is written in XML.

The JavaBeans class provides the data that goes into the contained components, receives data that comes out of the contained components and reacts to the events fired in the page.

This clear separation of concerns lets the various role players in a team play their part without stepping on each others' toes.

A Tapestry application is a bunch of web pages managed by a single central engine. The application is defined in an XML specification file that identifies the engine, the pages and other components that make the application.

Every Tapestry application has a single entry point via the ApplicationServlet. The ApplicationServlet gateway is a Java servlet that is identified in the web.xml as per the servlet specification.