Java Development News:

Tapestry In Action

By Kris Thompson

01 Mar 2004 | TheServerSide.com

Introduction

A few months ago while I was at the NFJS conference in Denver Colorado I was talking with Erik Hatcher about why he liked Tapestry so much. While his story wasn’t convincing enough for me to drop everything and check it out, it was enough for me to closely watch the project. For those of you who haven’t heard or played with Tapestry here is a quick elevator explanation. Tapestry is one of the three Jakarta sponsored web frameworks, http://jakarta.apache.org/tapestry/. Unlike the other two, Tapestry is very component centric in its design. Tapestry is not a new framework, it has been around for a while and has recently gained a lot of popularity due to the abuse URL-based or command-driven frameworks have been getting and the general attention to a component-based approach to web development, since this model is similar to JSF. This will simply be a review of the book, Tapestry in Action, not the framework, which I hope to leave for another time. I hope you find it useful!

Download Sample Chapters from Tapestry In Action

Part I The Introduction and the Basics

There are two parts to the book as I see it. Chapters 1-5 is part 1 and 5-10 is part two, however this isn’t explicitly defined that way in the book. The first part introduces you to web applications, then reviews the history of it and describes the problem space developers have to operate in and lastly what makes Tapestry unique from the rest. This part also covers the basics of Tapestry, how to get started and some of the core concepts. Upon reading this part developers should be able to make a decision if Tapestry is right for them and they should be able to gain enough knowledge to create some simple apps. If you just want to flirt with Tapestry than all you need is part 1.

Interested in writing a book report for TheServerSide? Email bookreports@theserverside.com

Chapter1 Introducing Tapestry

Howard starts off his journey into Tapestry with a long winded introduction on the history of the web and Servlets. The story is needed in order to explain the decencies with a more popular web framework.

     “Struts standardizes some common patterns and techniques that would otherwise
need to be re-invented by each developer, but it is still fundamentally similar
to ordinary servlet development. Whether developing using just servlets or with
servlets augmented by Struts, you will still encounter some significant limitations
in the basic development model that you must overcome.”

He continues to illuminate the issues with Servlet development such as Weak Binding which has been a topic of interest recently. Weak Binding is mainly due to the fact that Servlets are held together by URL’s not method signatures. Weak Bindings rely heavy on the developers to make sure that the “glue” that associates the Servlets and JSP’s is done correctly; no IDE can find these errors at compile time. Of course with all this build up of problems with popular modern day Servlet development he throws out why Tapestry is your salvation, and he keeps throwing and throwing and providing you with tons of reasons to use Tapestry. Let me sum it up for you, Servlets are operational centric while Tapestry is component centric, hence it is a component web framework!. Consider chapter 1 to be the Executive Summary for the book and the project.

Chapter 2 Getting Started with Tapestry

Here is where I couldn’t disagree more with the book reviewer on Java Ranch. If you are limited on time for just one chapter, this is it. The more challenging part in starting a new framework is getting started and this chapter explains the basic foundation of working with Tapestry by building a hangman example as the example in discussion. Maybe the example he used is a little to basic and doesn’t resemble a “real” application, however the Wafer Weblog is basic but this gets the point across. This chapter was so concise and easy to follow that I felt I could create my Wafer weblog easily from having read this chapter or at least the more difficult part of getting started would now be behind me. If only the other frameworks I have worked with and wrote about came with this much clearer information. Kudos to Howard on this chapter! Luckily for you Chapter 2 is one of two chapters they have made freely available online for you to view and all of the code discussed is also online to view. Manning and Howard, you rock!

Chapter 3 & 4 HTML Forms

Good chapters on core concepts and written in the same clear and concise style as the first two chapters. Sometimes I am a little amazed and bored by the level of detail Howard covers; however, my boredom is largely due to the fact that I don’t need this knowledge because I’m not actively developing in Tapestry. I would find this excessive detail to be a gem if I were developing with Tapestry.

Part II The meat of the framework

From chapter 5 and on it covers core advanced topics on developing with Tapestry. Unless you are actively on a Tapestry project or will be soon you can stop here because from this point on the level of detail that the book goes into is more than most can or should retain in the heads for no useful purpose.

Chapter 5 Form Input Validation

This chapter goes over, in much detail, how to use validation which might be fun just to skim through. The only really interesting and unique issue here is Tapestry’s client side scripting which I find interesting and really want to see operate in action especially since this will be a hot topic over the next year or so with JSF slowly coming onto the scene. For those wanting to take a cost free peek at this chapter you can download it from the Manning web site.

Chapters 6, 7 and 8

Chapters 6, 7 and 8 are way too verbose even for a web frameworks junkie like myself to enjoy but again I would find them very useful if I were actively coding with Tapestry. Normally, to get information like this requires developers to either whine on the mailing list of the framework of choice or download the source themselves to understand the deep secrets of the framework. So either you will find these chapters to a total bore or a valuable reference for those times of need. The only thing disturbing I found was that in Chapter 8, Advanced Techniques, they have a section on integrating with JSP’s. Is Integrating with JSP’s an advanced topic?

Chapter 9 Designing a Tapestry Application

Chapter 9 is a good read for the “architects”, providing them with higher level topics like how to design a Tapestry application’s access and flow. No better way to explain how to do this but with an example, the Virtual Library. Unlike the examples provided before, this one doesn’t cover the details of the code but more the concepts of the previous chapters and showing how they all fit together. I only wish this example would have been included with the source, leaving it up to the user to view the source.

Chapter 10 Implementing a Tapestry Application

Finally, Chapter 10 provides developers currently working with Tapestry the resources and information to do those common tasks that aren’t always documented, kind of like a “best practices” chapter. It discusses such topics as integrating with EJB’s, authenticating users, adding security to pages along with others.

Extras on the Manning website

This is more than just a book. Manning has a site, http://www.manning.com/catalog/view.php?book=lewisship dedicated to it with resources used in the development of the book like source code for the examples, sample chapters and an example application. The source code comes with an eclipse project file and with a few simple modifications of a build.properties file you will be on your way to building and deploying the examples described in the book. Now that is red carpet treatment! Even if you didn’t want to buy the book the source is a wonderful example to help a Tapestry newbie get started.

Conclusion

If you're going to be working with Tapestry then there is no doubt that this IS the book you want and if you are wondering if Tapestry is right for you, read Chapter 1 or 2, if you're sold than this book will finish your appetite for knowledge. Who else would be more qualified to write the book than Howard Lewis Ship? While I do think the book got very verbose at times, as long as you don’t let yourself drown in details, you will find it useful. This book reaches many different audiences with the beginning dedicated to the developer just flirting with Tapestry to the middle chapters strongly geared to the Tapestry Power user, and the final chapters to the Architect. Whether you want or should use Tapestry is up to you, hopefully this book did help you answer that question and it definitely will guide you along that journey if you so choose to make Tapestry your framework. My rating of this book, if you’re going to, currently are or are thinking about working with Tapestry then you can’t go wrong with this book; however, if you strongly feel that IBM 370 assembler is the future then maybe this book isn’t so great.