In this article we'll begin by taking a look at servlets and JavaServer Pages, then proceed to learn about the MVC design pattern. After examining the problems these technologies solved, we'll focus on the Tapestry framework, study its advantages, and dispel some prejudices about it. This is the first article in a multi-part series covering Tapestry.
Well, it does, in some sense. But the only reason for this steepness is that Tapestry's documentation is incomplete and there are very few sources of information about it.
In fact, the only book on Tapestry that I would wholeheartedly recommend is "Enjoy Web Development with Tapestry" by Kent Tong (http://www.agileskills2.org/EWDT/index.html). This book helped me enormously when I was learning Tapestry 3; it is regularly updated, so now it is available for Tapestry 4.1. You can download the first four chapters of this book for free.
In order for a software solution to become popular, a number of different sources of information are needed, written in different styles, and this is what Tapestry is missing. The book by Kent Tong is excellent, but it is very concentrated, and many people might find it hard to read and follow. I feel like a gentle introduction to Tapestry is needed, with plenty of time spent discussing different things and looking at them from different sides. And this is what I am going to create here.
Prejudice 2: Tapestry is just another MVC framework. Why would we need yet another one when we already have Struts?
This is completely wrong, as Tapestry is very different. It is much more advanced than Struts. If my reasoning in the previous sections didn't convince you, try to follow the coming chapters of this tutorial and see if they can do something for you.
In fact, I find that Tapestry can be most difficult to understand for experienced Struts developers. This is because they are used to the peculiar Struts way of doing things and to the fact that there are several frameworks out there which are simply variations of the Struts approach.
So a Struts developer, looking at Tapestry, tries to find some version of Action classes, familiar views and controller, some tags to stuff them into views, some extensive configuration files... There is even a book that tries to follow this approach ("Art of Java Web Development" by Neal Ford), but the result is just a misunderstanding.
I think it might be important to understand that to achieve a clean separation of concerns, there is no need to literally embody the MVC pattern by putting all views into one room and all code into another room, and then writing an extensive configuration to keep track of them all. Tapestry is a good example of a creative and successful alternative approach to the problem. Its templates are similar to views, its page classes are similar to controllers...
But you are definitely fed up with theory for now, aren't you? Let's go to practice then.
What comes next?
First of all, we shall need to have a working configuration of a few pieces of software that will enable Tapestry development. In fact, this configuration will be more or less the same as for any other kind of Java Web development: a Java Development Kit (JDK), an Integrated Development Environment (IDE) and a servlet container.
The most popular approach is to use Eclipse as an IDE and I will give some pointers on creating an Eclipse-based configuration. But I have found that NetBeans IDE can provide an even shorter path from installation to deployment, so I am planning to make NetBeans the main tool for this tutorial. I know that there is a Tapestry module for NetBeans being developed, and we are going to adopt it at some point.
We shall have a look at the standard structure of a Java Web application and how Tapestry applications reflect it. Finally, we shall build our first simple Tapestry application and discuss how and why it works.