HomeApache Page 2 - Creating Your First Tapestry Project
Adding Tapestry - Apache
In the previous article, we began moving from theory to practice by preparing our work place and setting up our system. In this article, we actually get our hands dirty (at least figuratively) by building our first Tapestry project.
So far, we have dealt with a generic Java Web application. Now we are going to add Tapestry. Basically, Tapestry is just a set of libraries that bring with them a lot of important and useful functionality.
One way to obtain these libraries is to go to the Tapestry website (http://tapestry.apache.org/download.html) and download a binary package acceptable for your platform. I recommend that you choose version 4.1.1. Although it is stated that it is "still undergoing lots of active development," it is also considered to be "stable enough." The downside of this approach, i.e. downloading the libraries from the Tapestry website, is that the libraries are packaged in a somewhat inconvenient way -- every single library is put into a separate subfolder.
For our purposes, it will be more convenient to put all the JAR files together into one folder. You can repackage them yourself, or you can simply download the package that I have already created for you; please go to the beginning of this article and click on the appropriate link.
Unpack the libraries into some folder on your hard drive. In my case, I have put them all into the tapestry41 folder in my home directory.
Now, if you expand the Libraries folder in the Projects view of your NetBeans IDE, you will see that it already contains JDK and Bundled Tomcat libraries. Right-click (or Ctrl-click on a Mac) on the Libraries folder and choose Add Library... The Add Library dialog will appear, similar to this one:
We don't have any Tapestry libraries here yet, so we need to add one. Press the Manage Libraries... button. The Library Manager dialog will open as shown below:
Now press the New Library... button and in the dialog that opens, enter a name for the new library, such as Tapestry41. Press OK.
Back in the Library Manager, make sure that the name of the new library is selected in the Libraries view on the left side and press the Add JAR/Folder... button. In the Browse Jar/Folder dialog that opens, navigate to the folder where you have unpacked all the Tapestry-related JAR files and select them all, then press the Add JAR/Folder button. Yes, I know, it's too many dialogs and buttons for such a simple operation, but we need to do this only once; any other projects you create in the same IDE will simply make use of this new library. The final result should look like this:
Press OK and then, back in the Add Library dialog, choose the newly added library and press the Add Library button. Phew... A bunch of files gets added to the Libraries folder of your project and now, not only is the IDE aware of all the classes you will need for Tapestry development, but these libraries will also be packed into the final package with the application we are going to create.