Joshua has posted 1 posts at DZone. View Full User Profile

Why You Should Consider Tapestry 5

  • submit to reddit
Tapestry 5.0.14 was released recently and the Tapestry community is very excited with this news because Tapestry 5 is only one step away for being GA. In case you haven’t heard of T5, it’s an opensource component based web framework which is a total revamp from the previous version. Some people may not like the previous version because of the learning curve on using it. Some people even wrote rants about the previous version. But T5 is totally a different architecture with the same way of thinking as the previous version. So what’s so good about T5? And why should you consider it for your next project? Here’s my personal reason based on my experience building my opensource project using T5.

  1. Create custom components easily and quicker
  2. Think about creating custom components with Taglib, or even worse think about creating custom components with JSF. Forget about those scary days, now creating components with T5 is so much fun because basically it is just a plain POJO, which means you can unit test your custom components. Here’s a simple example of a T5 component:

    public class AddChar {
    private String value;

    private int position;

    private String character;

    void beginRender(MarkupWriter writer){
    StringBuffer sb = new StringBuffer(value);

    sb.insert(position, character);


    And here’s how we call it from our page template:

    <t:addChar value="literal:HelloWorld" position="5" character="literal:-"/>

    Or if you prefer to embed it in your html tag so your webdesigner can use his/her favorite html designer to preview it, you can use it as such:

    <span t:type='addChar' t:value="literal:HelloWorld" position="5" character="literal:-"/>

    Isn’t that too easy to be true? Okay okay, I know it’s a very simple component, but don’t think of the complexity, but think of how many files artifacts you have to manage compared to making components in Struts2, Tapestry 4, JSTL, or even JSF. Whoops, I didn’t mean to bring a web framework bashing forum here but I need to mention the name of the framework so you’ll get the idea what I’m talking about. I’m the kind of guy that really likes creating component, and back in the past creating custom components with frameworks with Struts really frustrates me. But now with T5, I found it very amusing.

  3. Easy to create templates
  4. How do we create templates in T5? (The tapestry community calls this as Layout or Border, a term inherited from Tapestry 4. But I’d just call it as templates as more people are more familiar with the term). You’ll be surprised that all you need to do is create a dummy component (as I call it) under the components package as such:

    @IncludeStylesheet( "context:css/myapp.css" )
    public class Layout {


    Then create the template with the same name as the component class (Layout.tml) as such:

    <html xmlns:t="">
    <title>Tapestry5 Experiments</title>
    <div id="wrap">


    The <t:body> element really tells you to insert the body of your page fragment. And this is how your page fragment would look like:

    <t:layout xmlns:t="">
    <div id="right">

    And below is the page class where you normally write down your logic:

    public class Search {


    In an action based framework this is what is called as Controller where you write down your front end logic. And yes, that’s it. Just believe it. Everything is very natural and from my experience it can really help you speed up the development performance. Forget about third party components like sitemesh or tiles just to have templating in your project and the number of file configurations you have to manage.

  5. Less XML configurations to be maintained and configured
  6. Many of the configurations is configured inside web.xml and the rest lies inside a Module class inside the services package. This approach is much better because by putting configurations inside java classes you are assured to get typesafety accross your applications. Here’s an example of the configuration inside web.xml:

    <web-app xmlns=""

    <display-name>Tapestry5 Experiments</display-name>






    web.xml will be the only xml file you have to manage with T5. Most of the configuration of T5 apps will be configured inside a Java class. The Java class for configuration will be as the name is taken from the filter name configured in web.xml and the content of the Java class will be as such:

    * Note: this is a default configuration that you will get when you create the project using maven archetype

    public class AppModule
    public static void bind(ServiceBinder binder)
    // binder.bind(MyServiceInterface.class, MyServiceImpl.class);

    // Make bind() calls on the binder object to define most IoC services.
    // Use service builder methods (example below) when the implementation
    // is provided inline, or requires more initialization than simply
    // invoking the constructor.

    public static void contributeApplicationDefaults(
    MappedConfiguration<String, String> configuration)
    configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
    configuration.add(SymbolConstants.PRODUCTION_MODE, "false");

    I found it very helpful to have your configuration in a Java class as you can find problems earlier. Also in an more advanced usage, this way of configuration in Tapestry 5 can lead you into building a modular and plug & play components.

  7. Convention over configuration
    1. The Page classes are all located under yourpackage.pages
    2. The Component classes are all located under yourpackage.components
    3. The Service classes are all located under
    4. and if you use T5-hibernate all of the Model classes are located under yourpackage.entities
  8. Well it’s not like CoC as in Rails, but at least it helps us cuts down things that can be a convention instead of using a configuration. And it does really helps during development.

    The reason why XML configurations has got less XML configurations because many of the configurations is addressed through CoC. How does T5 implement CoC?

    yourpackage gets its values by setting this configuration:


    inside web.xml

  9. Integrate seamlessly with groovy
  10. You don’t need special configuration to be able to use groovy in your T5 apps. Just use it and T5 will recognize your .groovy files straight away. Use it anywhere you want: As your Page class or Service class or even DAO class. And why is this important? Because with Groovy you can cut down some boiler plate code.

  11. Built in pretty URL
  12. You do not need a urlrewritefilter framework just to get pretty URL or RESTful URL with T5, because it’s a built in feature without any further configuration. The URL will be generated by the framework based on the structure of your Page class under yourpackage.pages package. So if you have a View class under department package:
    |- yourpackage
    |– department
    The URL that will be generated is: http://localhost:8080/yourapp/department/add

    This is a big leap forward because the previous version, T4 has got a really ugly URL by default, and you must configure it to get the pretty URL.

  13. Built in Ajax
  14. Ever wonder you’d want a validation on the client side in an AJAX way but integrate it in an easy fashion? No worries, since this AJAX validation is built right in. And what’s even great it is like an event bubbling where everytime there’s a mistake in the form input, it will point at you the field where there’s a mistake. As far as I know that not many JVM web framework has this feature out of the box, in Seam you have to combine it with a s:decorator to get the Ajax validation feature and in the end it will make your code look verbose.

    Tapestry 5 also lets you return a partial fragment to your page by using the zone component. Another interesting Ajax feature in Tapestry 5 is the ‘google suggest’ like component where you can return result based on what you type in your text input. Under the hood, T5 is using Scriptaculous and Prototype as its Ajax framework. To get a better idea about the Ajax features in T5, you can read it from the documentation here.

  15. Lots and lots of interesting built in components
  16. Besides the Ajax components that I told you in previous point, there are many built in components in T5. Many times you’re found not having to create your own component because the ones that is provided by T5 might be better or just the ones you need.

    One built in component that I’ve found very interesting is the Grid component. The Grid component is where you display your list of data in table. What makes it interesting is, it has built in sorting and pagination feature. Normally with other framework you have to implement this by yourself, or even use a displaytag library. In Flex, I found it frustrating because it hasn’t got pagination feature for the DataGrid component. Now do you want to see how much code is required to make a datagrid that has pagination and field sorter header?

    <t:grid source="users" row="user" rowsPerPage="5"/>

    Well, believe it. To get the idea of the built in component that T5 has, check it out from the documentation here.

  17. Seamless integration with Hibernate
  18. The integration with Hibernate makes T5 looks like a full stack web application framework. It has the declarative transaction annotation just like the @Transactional annotation in Spring or Seam. In T5 you just annotate your method with @CommitAfter to get the declarative transaction feature.

  19. Seamless integration with Spring Framework
  20. Even though Tapestry 5 has built in Dependency Injection, but somehow you want to use Spring and inject Spring beans into your T5 apps. You can’t imagine how easy it is to do this in T5.
    You need to change the filter name to use the TapestrySpringFilter in web.xml class as such:

    <!-- Special filter that adds in a T5 IoC module derived from the Spring WebApplicationContext. -->

    And Tapestry 5 will recognize your Spring bean and you can inject it with T5’s @Inject annotation in your Java class as such:

    private UserDAO userDAO;

    Okay basically what that code snippets does is that it will inject your Spring bean that is called UserDAO. It’s that simple.

  21. It just gets better
  22. For the last reason, you may consider it or you may not. Just consider it as a bonus from me. Okay, some people just hates frameworks that just keeps changing almost every single day. But what if I tell you that T5 keeps changing or should I say evolving into something better and better every single day? This can only happen because of the vision of the man behind this framework. The groovy integration that I’ve told you was added recently. And the next thing coming up is the Spring Web Flow integration. Another thing you would be surprised of is though many people have used this framework in their production environment but the author still consider this framework as a Beta. So you’ll get the idea how good it will be when it becomes a GA release.

From my point of view, T5 is filling the space in application framework the same way what Spring framework and Seam is doing. It has everything you need out of the box. I think Tapestry 5 appearance to the surface is great for the community as it adds more choice for the developers to use the relevant framework for their project. What I’ve written is just a small portion of the goodness of T5 and of course it’s what I liked most about T5. The list can go on, as I said it just keeps getting better everyday. But don’t just take my word for it, go ahead and take a look at it. You can start by reading the documentation first to get the overall idea of T5. Hopefully you can find yourself among many other developers that have enjoyed using it since it is first released to the community around a year ago.


Published at DZone with permission of its author, Joshua Partogi.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)



John Denver replied on Fri, 2008/08/22 - 10:05pm

Great article, Tapestry 5 is a great framework everybody should try it before come to conclusions.

T5 is very stable, mature and have all the features of a modern web framework. Really Im more productive with T5 than Rails and as the author said if you want to use a scripting language instead you can use groovy out of the box. T5 have great performance, Also it will never suffer a rewrite anymore Howard already said it many times, the archictecture of T5 is very cleaver for plug new functionality without rewrites.

I think Tapestry is one of the best web frameworks out there even I could use it as a specification for new web frameworks.

Congratulations to Howard and all the Tapestry 5 contributors.

Best Regards.


James Selvakumar replied on Sun, 2008/08/24 - 8:39pm

One of the best technical articles I ever read. You have motivated me enough to have a go at Tapestry 5.

wei shuwei replied on Mon, 2008/08/25 - 7:08am

Who can tell me,How long Tapestry5 will be released?

David Lee replied on Tue, 2008/08/26 - 10:49am

I attended a NFJS conference this past weekend and when the audience was asked how many people are doing JSF, about 2 people (out of about 100)raised their hands.  About a quarter to 3rd of the sessions were JSF related in some way, and JSF interest was close to nil.

One of the panel members went on to say that the industry is consolidating around grails, spring mvc and JSF.   I'm thinking, if that's true, then the industry is just wrong.  Spring MVC brings nothing new to the table and JSF has been DOA from the beginning.  

I hope the industry will stop the herd mentality and reconsider Tapestry.  In my opinion, the industry needs to be consolidating around grails, wicket and tapestry.

Tapestry 5 is pretty impressive. 

Yeah it sucks that backwards compatibility hasn't been there but I would love to hear someone make the case that JSF is superior in any way other than being Sun supported.  It also sucks that Sun seems choose wrong so often, ie jruby over groovy.

John Denver replied on Wed, 2008/08/27 - 4:13am

@David Lee Im agree with what you said.

As you said why always Sun go the wrong way?.

1.Tapestry 5 supports Groovy(you can create the POJO's with groovy).

2.Spring MVC is cool and Action frameworks still have their place so Grails and Spring MVC is also a good choice.

3. Wicket have good things too, Maybe can use it with groovy?.

Also let me tell you I have evaluated ZK framework, GWT and Echo for full Ajax framework and my choice is ZK it is very easy to use, it rocks, have already books, the docs are great, really imagine how you program Flex 3 but instead of AS3 you use Java, take a look at ZK.

 Anyway JSF2 looks promising I hope they succeed because I dont like to see a Java framework fail.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.