Tapestry

Welcome to Tapestry's Hotel Booking demonstration
This is a demo app, an introduction to basic Apache Tapestry functionality in the form of a hotel booking simulation.

Find a Hotel

Hint: try Marriott or San Francisco or *

How this works

This is the home page of the Tapestry Hotel Booking demonstration app. This page is constructed by Tapestry using an HTML-formatted template file, Index.tml. The small amount of code supporting this page is in the correspondingly-named class file, Index.java. Generally, every Tapestry page has a template file and a class file sharing the same name.

The overall layout of all pages in the app (the common header and footer elements, for example) is controlled by the Layout.tml template. This page (like most of the others) explicitly wraps itself in the Layout component by specifying <html t:type="layout".../> at the top of its template file.

This page uses Tapestry's Form component, taking advantage of its async feature. When you "submit" the form, Tapestry-supplied JavaScript submits an AJAX request to the server and gets back a JSON object containg one or more blocks of HTML, and updates just those portions of the page.

You don't write any JavaScript (unless you want to).

Surprisingly, the app works just fine without JavaScript too, which is good for SEO and accessibility.

The <t:zone> component in this page's template file (Index.tml) surrounds the HTML elements for the layout of content within the area to be updated. In this case, those HTML elements consist of an HTML table produced by Tapestry's built-in Grid component (which only appears when there are search results to display).

The Grid component (<t:grid>) generates an HTML table from a collection of JavaBeans (one per table row) with built-in JavaScript for sorting and pagination. The built-in Hibernate module comes with an optimized version of GridDataSource to create efficient database requests for page-at-a-time retrieval of data.

Also, we're using the Grid component's built-in partial refresh option ("inPlace") that allows pagination and sorting to occur without redrawing the whole page.

Finally, the links in the first column are built with Tapestry's PageLink component, which in this case constructs a URL that includes an "activation context" (the part of the URL after the page name) consisting of the primary key of the record in the database corresponding to each table row.