Skip to main content

skip to main content

developerWorks  >  Java technology | Open source | Web development  >

In tune with Tapestry, Part 1

Get Tapestry up and running in your Java environment

developerWorks
Document options

Document options requiring JavaScript are not displayed

Discuss


Rate this page

Help us improve this content


Level: Introductory

Brett D. McLaughlin, Sr. (brett@newInstance.com), Author and Editor, O'Reilly Media, Inc.

04 Jan 2006

In this first half of a two-part article, author and frequent developerWorks contributor Brett McLaughlin shows you around Tapestry, from installation to file structure. See for yourself how Tapestry facilitates servlet-based Web application development using HTML and template tags.

Having an online presence is essential if you want to sell a product, whether you run a multimillion dollar corporation or just want to unload a few thousand hemp bracelets over the holidays. In some cases, it's good enough to cobble together some Web pages and use a prepackaged payment system like PayPal or eBay for sales transactions. But a comprehensive, well-designed Web application can elevate your online sales from the bush leagues to those of a professional, dynamic, online store. And everyone knows consumers buy more from a store than they do from the flea market.

The trouble is, when you get into most Web development frameworks -- especially if Java™ is your programming language of choice -- you find at least as much complexity as usability. Struts, JSF, and Spring are all great Web development frameworks, but none of them is for the faint of heart. (If you've ever tried explaining inversion of control to a new Java developer, then you know what I'm talking about!) Fortunately, there is an easier option.

Tapestry, an open-source, Java-based framework released under the Apache Software License, is specifically designed to simplify Web-based development. Consider the following key features:

  • It's easy to install: You don't need to be a Web application guru to get Tapestry up and running.

  • It's easy to use: You don't need much more than basic Java and HTML (yes, that's HTML, not servlet) skills to write Tapestry applications.

  • It's easy to scale: You won't have to dump Tapestry when your site grows beyond 10, 50, or 100 pages. Tapestry is robust enough for most Web applications.

In this article, the first of two parts, I'll get you started with Tapestry. I'll take you through the steps of downloading and installing the framework, and then I'll run through some sample applications that will give you an idea of how it works. In the next article, I'll get into more advanced examples that will improve your grasp of the core Tapestry framework. Before you know it, you'll be completely comfortable in the Tapestry environment.

Installation simplified

You'll quickly learn that the watchword in Tapestry is simple. That's not simple as in primitive or lacking sophistication, but simple as in easy to understand, usable, and intuitive. Because installation is your introduction to any new technology, it goes without saying that installing Tapestry is very easy. For starters, there are just a few prerequisites, and they're all pretty standard for Web developers, so you may already have them installed. (See the Resources section for technology downloads if you don't.)

Annotations in Tapestry

One of the new features in Java 5.0 is the annotations syntax. With annotations, you can mark up your code using a style very similar to inline comments starting from the @ symbol. You use annotations to add metadata to classes, which can then be used by a compiler or framework such as Tapestry. Specifically, Tapestry lets you use annotations to describe behavior in code that would otherwise have to be defined in extra pages or components. See Resources to learn more about annotations in Java 5.0.

Prereq 1: Java 5.0

Obviously, the first requirement of using Tapestry is that you have the Java platform running on your machine. While Tapestry works with almost any relatively modern version of Java (think Java 1.3 or later), you're best off using Java 5.0. Several optional features in Tapestry will work only with Java 5. And besides, there's really no reason not to move to Java 5 at this point: it's stable, well-tested, and past its initial growing pains.

Prereq 2: A build tool

Along with a JVM and a servlet engine, you also need a build tool like Apache Ant. While Ant is pretty easy to download, you do need to make sure that the Ant binary (either ant for Linux/Mac OS X systems or ant.bat for Windows systems) is in your path. If you type ant into an empty directory, you'll probably get something like this:

Buildfile: build.xml does not exist!
Build failed

Prereq 3: A microkernel

Finally, you need to install a microkernel, namely HiveMind, to register the objects for your Tapestry applications. I won't discuss HiveMind in detail in this article -- it's worthy of a few articles on its own! -- but you will see for yourself how Tapestry uses it. After you've downloaded HiveMind from the Jakarta Web site, place it in the same directory where you've stored Tapestry; for instance, you might use /usr/local/java/hivemind-1.1 or C:/java/hivemind-1.1. Any location is fine, as long as you remember where you've stored it!

Tapestry actually has quite a few more dependencies, but with HiveMind, Ant, and Java 5.0 installed, you can let Tapestry handle the rest of the dependencies for you. Because Tapestry is a framework for Web applications, you'll also need a servlet engine like Apache Tomcat (see Resources) when you're ready to run your apps. Tapestry applications are packaged as WAR files (Web application archives), so you can drop them into any servlet engine's Web applications directory. Tomcat is used in the examples throughout this article, but you can easily use Tapestry with the servlet engine of your choice.



Back to top


Download Tapestry 4.0

Once you've got all your prerequisites in place, head over to the Jakarta Tapestry homepage (see Resources) to download Tapestry from an Apache mirror. Start by selecting the latest version of Tapestry 4.0, which as of this writing is tapestry-4.0-beta-12.tar.gz (Windows users, grab the .zip equivalent). In general, it's best to learn a new framework with stable code, rather than newer beta code. However, Tapestry 4.0 is nearing the end of its beta cycle as of November 2005 and offers significant improvements over Tapestry 3.x. (By the time you're reading this article Tapestry 4.0 may be available.)

While you're at it, you may also want to download the documentation set. As of this writing, that file is called tapestry-4.0-beta-12-docs.tar.gz. Expand this archive and you should get a new folder named tapestry-4.0-beta-12, though the name may change if you've downloaded a newer version of Tapestry.

Move this folder to where you prefer to keep your Java project installations; a location like /usr/local/java is great, or you might consider C:/java. In either case, you'll end up with a new Tapestry directory. Inside that directory is quite a bit of information; check out Figure 1 for the top-level directory structure:


Figure 1. The Tapestry directory structure
Tapestry has pre-built JAR files and lots of source code

Tapestry is standing by!

The term installation is a bit of a misnomer when applied to Tapestry. Tapestry isn't like a Java application that runs in the background or a servlet engine that serves up content over a network. Instead, it's a set of utilities -- from classes to tags -- that you use in your applications. So rather than "installing" Tapestry, you make it available to your Web applications and bundle Tapestry and its dependencies with your Web applications.

Change, change, change

Your JAR files may have slightly different names, matching the version of Tapestry you downloaded. The four JAR files should exist in all Tapestry installations, though, regardless of the main version number of Tapestry.

Setting up Tapestry mainly involves putting the right groups of classes -- bundled into Java JAR files -- in the right directories. First, you'll need to locate the core Tapestry JAR files. These files contain all the Tapestry code you'll use in your Web applications and are located in the root Tapestry distribution directory:

  • tapestry-4.0-beta-12.jar contains the bulk of the Tapestry framework.
  • tapestry-annotations-4.0-beta-12.jar contains classes needed to support Tapestry annotations on Java 5.0.
  • tapestry-contrib-4.0-beta-12.jar contains components that are contributed to Tapestry but are not required for operation.
  • tapestry-portlet-4.0-beta-12.jar contains the classes that enable Tapestry to support JSR-168, the portlet JSR.

Place all four of these JAR files in the WEB-INF/lib directory of any Web application using Tapestry and you'll be ready to go -- well, almost. You need to do just a little more setup before launching into the application examples.



Back to top


Setting up dependencies

Tapestry seeks to provide a simplified programming model and an easy-to-use environment for Web application programming. It does this by abstracting the details of repetitive and common tasks, for which it uses a lot of utilities. Whether it's supporting regular expressions or registering objects or creating fancy UI components, Tapestry depends on third-party libraries to make Web development as easy as possible for you, the developer.

Fortunately, Tapestry does the work of downloading and installing most of its dependencies for you. The only real hassle is keeping track of all those extra JAR files, but as you'll see in this section, that's not such a big deal.

Because Tapestry uses HiveMind to determine and download dependencies, your first step is to let Tapestry know where you've put the HiveMind files. Navigate into your Tapestry directory -- perhaps something like /usr/local/java/tapestry-4.0-beta-12 -- and then into the config directory. You should see a build.properties file. When you open it up, it will look something like what you see in Listing 1. Several of the core libraries and dependencies for Tapestry are listed here, along with their locations. This list doesn't reflect all of the dependencies needed by Tapestry, but it's the dependency set needed for compiling basic Tapestry applications.


Listing 1. The default Tapestry build.properties file


# Copyright 2005 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

jboss.dir = c:/Work/jboss-3.0.6

jython.dir = c:/Work/Jython21

jetty.dir = c:/Work/Jetty-4.2.22

tomcat.dir = C:/Program Files/Apache Group/Tomcat 4.1

hivebuild.dir=c:/workspace/jakarta-hivemind/hivebuild

clover.dir=c:/Work/clover-1.0

jboss.dir=C:/jboss-4.0.2

If these projects and the locations assigned to them look odd to you, that's okay. You actually should clear out everything in the properties file except the lines that begin with hivebuild.dir and tomcat.dir because those are the dependencies you likely already have in place. Change the location to match where you installed HiveMind and Tomcat and your final version of build.properties should look similar to what you see in Listing 2:


Listing 2. A modified build.properties file


# Copyright 2005 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

tomcat.dir=/usr/local/java/jakarta-tomcat-5.5.9

hivebuild.dir=c:/workspace/jakarta-hivemind/hivebuild

Save this file and return to the root Tapestry directory to set up Ant.

Setting up Ant

The Ant install is pretty simple, although it does take some time. Start by typing ant install in Tapestry's root directory. All sorts of text will fly by until you get to a fragment that looks like this.

The strange formatting isn't anything to worry about; type "continue" and press Enter to start downloading Tapestry's additional dependencies. This step actually takes some time, so don't worry if the build seems to go on for a while: several libraries will be downloaded and lots of code compiled. You'll even see several tests installed, and then probably get the following (apparent) error.

For advanced developers

If you want to use additional projects in your Tapestry development, you can simply change build.properties to reflect the locations of those projects. Then, just remove lines for any projects that you don't have and let Tapestry download your actual dependencies.

Don't be thrown by all the error messages: just be sure you read the output of the various echo statements; they indicate that once JUnit has been downloaded and installed, you simply need to restart the build process.

Building and more building

That's right, you're not done yet. At the prompt, type ant install again to resume the build. With JUnit installed, the build runs a number of JUnit tests, to ensure Tapestry is correctly set up . Because this build will take quite a while, go get a coffee or code some XHTML on another computer. The tail end of the build should look like this if things went well.

What are all these libraries?

Once the build is complete, navigate to the ext-package/lib directory and do a directory listing. You should see a list that looks like this:

[bmclaugh:/usr/local/java/tapestry-4.0-beta-12/ext-package/lib]$ ls
cglib-full-2.0.1.jar                    jdom-1.0.jar
cglib-full-2.0.2.jar                    junit-3.8.1.jar
commons-codec-1.3.jar                   log4j-1.2.8.jar
commons-fileupload-1.0.jar              ognl-2.6.7.jar
commons-logging-1.0.4.jar               oro-2.0.8.jar
easymock-1.1.jar                        portlet-api-1.0.jar
easymockclassextension-1.1.jar          servletapi-2.3.jar
hivemind-1.1-rc-1.jar                   spring-1.1.jar
hivemind-lib-1.1-rc-1.jar               tapestry-4.0-beta-12.jar
javassist-3.0.jar                       tapestry-annotations-4.0-beta-12.jar
jboss-j2ee-3.2.1.jar                    tapestry-contrib-4.0-beta-12.jar
jboss-j2ee-4.0.0DR4.jar                 tapestry-portlet-4.0-beta-12.jar
jcharts-0.6.0.jar                       vlibbeans-4.0-beta-12.jar

As you can see, the build process downloaded a lot of extra libraries. Many of them are used in building Tapestry and several others are helpful for compilation. For run time, though, you'll need to place the following Tapestry JAR files in the WEB-INF/lib directory of your Web applications:

  • tapestry-4.0-beta-12.jar
  • tapestry-annotations-4.0-beta-12.jar
  • tapestry-contrib-4.0-beta-12.jar
  • tapestry-portlet-4.0-beta-12.jar

In addition, you'll need to place the following dependency files in the WEB-INF/lib directory of your Web applications:

  • commons-codec-1.3.jar: Files for URL encoding and decoding utilities.
  • commons-fileupload-1.0.jar: Libraries for handling multipart file uploads.
  • commons-logging-1.0.4.jar: The framework to which Tapestry logs information and errors.
  • hivemind-1.1-rc-1.jar: The service registry for Tapestry Java objects.
  • hivemind-lib-1.1-rc-1.jar: The HiveMind libraries.
  • javassist-3.0.jar: A runtime bytecode enhancement library.
  • ognl-2.6.7.jar: The expression language for navigating object graphs.
  • oro-2.0.8.jar: A regular expression library for pattern matching.

That may seem like a lot of files, but it's not unusual for a Java library; just drop them in the right place and you won't have to think about them again. The best news about the installation is that you're done! With the prerequisites installed and Tapestry and all its dependencies set up, you're ready to see what some Tapestry Web applications look like.



Back to top


Tapestry's example apps

Rather than building a Tapestry application from scratch, it's a good idea to start with the sample applications bundled with Tapestry. This way, you'll get a good idea of what Tapestry applications can do before you're in the thick of developing one yourself.

The first thing to do is navigate to your Tapestry directory and then into the Examples directory. You should see several directories, each with their own sets of files and subdirectories:

  • Workbench (in Workbench/) is a showcase for several of Tapestry's UI components, like tabs, tables, palettes, and validation.
  • Virtual Library (in Vlib/) is a complete J2EE application that uses entity beans and CMP (container-managed persistence), session beans, and of course, servlets.
  • VlibBeans (in VlibBeans/) are the beans used by the Virtual Library app.

You could compile these files using Ant, but that would involve setting up a database and then setting up Tapestry to communicate with it. That's a lot of work, so there's a nice shortcut you can use instead. Navigate to Howard Lewis Ship's home page (that's Tapestry's creator, by the way), and you'll see several files available for download. Select tapestry-examples-4.0-beta-12.tar.gz (your version may vary), start the download, and then sit back and relax because it's going to take a while.

The Workbench application

The Quick Start archive is a preconfigured set of examples that includes all the dependencies you'll need, including a ready-to-run JBoss application server instance. To run the Workbench application, expand the archive and locate the resulting folder to a directory that you can run the examples from; for example, C:/java/tapestry/jboss-tapestry-examples-4.0-beta-12/. Next, enter this new directory, and then the bin subdirectory. If you're on Windows, enter the command run; on Linux, Unix, or Mac OS X, enter sh run.sh (or whatever variant you want to use to run shell scripts). You'll see a lot of stuff go through the console, ending in something similar to this.

Tomcat twice?

Tomcat (or a similar servlet engine) is necessary for running Tapestry applications, so having it installed on your machine will come in handy when you start building an application from scratch in Part 2. If you already have Tomcat installed on your machine now, however, you'll need to shut it down before running the preconfigured examples, because the Quick Start archive includes a Tomcat installation. If your version of Tomcat is running when you start up the examples, you'll get a port conflict, because both Tomcat instances will attempt to use port 8080.

This script starts up the preconfigured instance of the JBoss application server (which in turn uses Tomcat as its servlet engine) on http://localhost:8080. Open up the Workbench app and you should see something like what's in Figure 2:


Figure 2. The Workbench application
The Workbench app shows off Tapestry's UI components

Go ahead and play with this sample application. Workbench lets you see how Tapestry handles internationalization (I18N), fields, graphs (shown in Figure 3), dates, color palettes, file uploads, and more. You can build each of these components with literally a line or two of code using Tapestry.


Figure 3. Tapestry's charting component, courtesy of jCharts
Tapestry uses supplemental libraries like jCharts for fancy displays

The Virtual Library application

Next, take a look at the Virtual Library application. If you've stopped JBoss fire it back up again, then navigate over to the Virtual Library app. This application isn't quite as flashy on the front end as the Workbench, but it gives you a feel for Tapestry running against a database using an EJB container (in this case JBoss, obviously).

If you want to get a feel for the application, start out by doing a search for a book; enter a title, author, or select a publisher (see the example in Figure 4):


Figure 4. A book search in the Tapestry virtual library
The virtual library shows off Tapestry's database interaction

Click the Login link on the left and enter username "ringbearer@bagend.shire" and password "secret". While this user has no books, it has been assigned administrative rights, so you'll see several new options appear on the left side of the screen (check out Figure 5). Play with these options and get a feel for how Tapestry runs. When you recall that Tapestry is a simple, template-driven framework -- requiring very little hardcore programming to get an application running -- you'll start to appreciate the complexity of these sample applications.


Figure 5. Extra options for administrative users
Tapestry  easily handles permissions and roles


Back to top


Hands-on examples

In addition to letting you see for yourself what Tapestry applications look like and how they run, the Quick Start archive includes more hands-on examples that let you get a feel for the structure of a Tapestry application. Navigate back to the archive and grab the file named tapestry-tutorials.tar.gz. Like the prebuilt Tapestry examples, the tutorial examples come essentially ready to run.

That's right -- Hello World!

Understanding these applications is pretty easy. Start by changing into the new directory created from expanding the archive and then into the helloworld/ subdirectory. While you could check out the source tree, source code organization is largely a matter of personal preference. Instead of spending time on that, try building the samples into a WAR file: type ant and let Ant build the Hello World sample app for you. The output isn't very exciting:

Buildfile: build.xml

compile:
 [mkdir] Created dir: /usr/local/java/tapestry-tutorials/helloworld/target/classes

war:
[war] Building war: /usr/local/java/tapestry-tutorials/helloworld/target/helloworld.war

BUILD SUCCESSFUL
Total time: 2 seconds

Ant has created a WAR file (in the target/ directory), which you can then drop into your Tomcat webapps/ directory (usually somewhere like /usr/local/jakarta-tomcat-5.5.9/webapps). Tomcat then automatically expands and deploys the WAR file as a Web application. The same holds true for the other tutorials, Direct Link and Forms, which you can find in their own directories under the tapestry-tutorials base directory. Figure 6 shows the Direct Link application running on Tomcat:


Figure 6. Direct Link running on Tomcat
Direct Link is a simple but a good demonstration of Tapestry at work

Application directory structure

You can use the Direct Link tutorial to become familiar with the Tapestry application directory structure. First, locate the preconfigured Quick Start Tomcat installation and change into the webapps/ directory. You'll see the WAR file you moved in -- like directlink.war -- but also a directory with the same name. This is the expanded WAR file, so change into that directory and take a look around. You'll see just a few files:

  • META-INF is the directory with the WAR file's manifest.
  • Home.html is the HTML template that Tapestry uses to display its main page.
  • WEB-INF is the directory with all the application's resources, the web.xml deployment descriptor, and property files.

Let's look at the Tapestry's HTML template and deployment descriptor files in more detail.

The HTML template

First, open Home.html and check out Tapestry's ultra-simple page design template; the file is also shown in Listing 3.

You'll learn a lot more about page creation in Part 2, but the main thing to notice for now is that, for the most part, Web pages in Tapestry are built using normal HTML with a few additional attributes. You don't have to code JSPs if you don't want to, and you don't have to throw your HTML into tons of servlet out.println() statements. Instead, you can simply create rich HTML (or XHTML) and CSS pages, add in a few Tapestry-specific attributes, and have a very dynamic application.

The upshot of all this is that you can easily have your entire site laid out by experts in HTML, CSS, and design using dummy links. When it comes time to deploy the app, you simply replace the links and components with Tapestry idioms. For example, notice that in Listing 3 the counter -- initially set to the default value of "37" -- is surrounded by span tags. Designers can easily surround dynamic values or sections with span or div tags. As the Tapestry developer, you then insert attributes like jwcid or listener to get a great-looking page without forcing your page designers to learn Java or the Servlet API.

The deployment descriptor

Listing 4 shows a typical deployment descriptor for a Tapestry application. As in any other Web application, this descriptor just maps a servlet to a name. Specifically, the Tapestry ApplicationServlet is mapped to the app URI. This is standard practice in Tapestry, and you'll probably want to drop this descriptor into all of your Tapestry applications. (You'll learn a lot more about this in Part 2.)


Listing 4. A sample Tapestry deployment descriptor


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/Web-app_2_3.dtd">

<Web-app>
  <display-name>Tutorial: DirectLink</display-name>
  <servlet>
    <servlet-name>app</servlet-name>
    <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>app</servlet-name>
    <url-pattern>/app</url-pattern>
  </servlet-mapping>
</Web-app>



Back to top


Show me the code!

By now, you're probably itching to see the actual code that makes Tapestry applications go. The big surprise is that there is hardly any code to see! While it's certainly possible (and even common) to write custom code, for many tasks, you don't need to go much beyond a basic Java class. In the case of the Direct Link app -- where you're displaying a dynamic value -- Tapestry and about 20 lines of Java code will give you all you need. Listing 5 shows the simple Java class that drives the counter for the Direct Link sample application.


Listing 5. The very simple Java of Tapestry


import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.html.BasePage;

public abstract class Home extends BasePage
{
    @Persist
    public abstract int getCounter();
    public abstract void setCounter(int counter);

    public void doClick(int increment)
    {
        int counter = getCounter();

        counter += increment;

        setCounter(counter);
    }

    public void doClear()
    {
        setCounter(0);
    }
}

There's a method to increment the counter and a method to clear it, and that's it! No HTML-specific logic, no fancy Tapestry interaction (other than that @Persist annotation, which I'll talk about in the next article), and just a couple of abstract methods to get and set the counter. With this class taken care of, you just need to let Tapestry know what identifier it should have so that page components like Home.html can access it. You'll do that through the app.application file, stored in the application's WEB-INF/ directory, as shown here:

<?xml version="1.0"?>

<!DOCTYPE application PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">

<application>
  <meta key="org.apache.tapestry.page-class-packages" 
  value="tutorials.directlink.pages"/>

</application>

Notice that the app.application file actually doesn't map the Home.class file directly to a name; instead, it simply indicates where the application should look for Java classes. So any Java references within your HTML pages will cause Tapestry to look in the tutorials.directlink.pages package. No direct mapping needed: any classes in that package become available to your pages. In this case, the name of the page (Home.html) is automatically matched up with a class by the same name (Home.class). Easy enough, right? All that's left to understand is how the HTML actually refers to specific actions and methods, in both Tapestry and the custom Home.class.



Back to top


Tapestry's component set

The last piece of this puzzle is the Tapestry component set used in the Home.html page from Listing 3. You'll learn a lot more about the Tapestry component set in Part 2, but here I'll cover the short version. Note that each component is prefaced with an @ symbol and annotated by the use of the jwcid attribute (refer back to Listing 3 to refresh your memory). These components interact with Tapestry and your custom class:

  • Insert does just what it sounds like: inserts a value into the page. The value in this case is ognl:counter, pulled from the Java class.

  • PageLink creates a link to another page; in this case, the link is to the same page, effectively causing a refresh.

  • DirectLink requests the Java component bound to this particular page (remember, the name of the page is matched with the name of the Java class). The listener attribute then allows specification of the method to call (doClear() or doClick()).

Obviously, there's plenty more to know about the Tapestry components. What about those short bits of text preceding @DirectLink like "by5" and "by10"? Why do you have to preface the method name in the listener attribute with "listener" (it seems redundant, doesn't it)? And what other components are built into Tapestry, in addition to PageLink and Insert? All those are good questions, but you'll have to wait until the next article to learn the answers. (Yes, that is what they call a cliffhanger ending.)



Back to top


Tapestry: Worth getting into

As I said at the beginning of this article, and as you've hopefully seen for yourself, the watchword of Tapestry is simplicity. While Tapestry is one of many options for Web development, it's unusual in that it lets you create Servlets-based Web applications using mostly HTML, some template tags, and some XML (which is optional in most cases). And, unlike other simple solutions for Web development, Tapestry scales up as your project grows -- even to tens of thousands of pages.

In the second half of this article, I'll dig a lot deeper into Web application development with Tapestry. I'll show you how to create Web pages and add placeholders for dynamic data. You'll then learn how to create Java classes, register them with Tapestry, and package them up as part of your Web application. I'll also show you how to use these Java classes from your pages, as well as some of the cool UI components that Tapestry offers. And through it all, you'll learn how simple HTML, template tags, and property files can add up to a killer Web application.



Resources

Learn

Get products and technologies

Discuss


About the author

Photo of Brett McLaughlin

Brett McLaughlin has worked in computers since the Logo days. (Remember the little triangle?) In recent years, he's become one of the most well-known authors and programmers in the Java technology and XML communities. He's worked for Nextel Communications, implementing complex enterprise systems; at Lutris Technologies, actually writing application servers; and most recently at O'Reilly Media, Inc., where he continues to write and edit books that matter. His most recent book, Java 5.0 Tiger: A Developer's Notebook, is the first book available on the newest version of Java technology, and his classic Java and XML remains one of the definitive works on using XML technologies in the Java language.




Rate this page


Please take a moment to complete this form to help us better serve you.



YesNoDon't know
 


 


12345
Not
useful
Extremely
useful
 


Back to top