Tapestry 5 – 10 Minute Demo of Apache Tapestry

This is a demonstration of about 10 minutes of programming in Tapestry 5 creating a sample application. The app is pretty basic and just lets you add URLs to a list and then vote on them-similar to the idea behind Digg or Reddit. I didn’t really explain things in great detail so it is more of a demonstration of some of the things you can do than it is a step by step tutorial.


General steps in making the application:

  • Create a Quickstart application from the Maven archetype.
  • Add the dependencies and configs for Hibernate.
  • Create an Item entity to store our url, title, and number of votes.
  • Use a BeanEditForm and onSuccess method to create Items.
  • Use a Loop to show the items in the database
  • Use an ActionLink and onActionFromVote method to count the votes
  • Add onValidate method to do validate the URLs.
  • Stick the loop in a Zone and update it with the ActionLink

The app uses the Quickstart archetype from 5.3 so it uses the new green theme.

Errata

  • I used @Component on the BeanEditForm, but I should have used @InjectComponent. As you can see in the comments, Howard isn’t really sure why this worked. So use @InjectComponent instead.
  • The zone should have gone around the ul elements instead of within it. The zone renders as a div and we shouldn’t have a div inside of the open/close ul.

About 

11 Replies to “Tapestry 5 – 10 Minute Demo of Apache Tapestry”

  1. Very nice, just a couple of notes:

    I tend to use no visibility modifier (that is, “package private”) for my event handler methods.

    On the Zone, I would have placed the t:zone around the <ul> I’m not sure you are rendering valid HTML putting the between the <ul> and the <li> elements.

    Lastly, I’m surprised the @Component annotation worked in your situation, you should use @InjectComponent when the component type is determined from the template, as in this case (i.e., <t:beaneditfor>

  2. Hi Mark,

    To a Tapestry greenhorn like me, video tutorials such as yours are a breath of fresh air. And you cover the vitals, such as Tapestry form persisted to database via Hibernate. Are you keen enough to produce an IntelliJ IDEA/Tomcat version?

    Kind regards,

    Chris.

  3. Hi Mark,

    Looks good. You have a pleasant recording voice, and the pace was about right–maybe a tiny bit fast for n00bs. You make it look easy, which is nice.

    In terms of UX, I guess that’s not the point here, but I’d try for something a bit more explanatory than “Invalid URL”; also I don’t recall if it indicates in the form where the problem is. Also, I’m a bit ambivalent about the automatic re-ordering of the list while you’re clicking on it–felt a bit too sudden, which could be disorienting to people. Plus, if they wanted to vote twice (if that’s allowed), they might think “I can click click” and then find they voted for the wrong one because it moved–so you might add a delay.

    Lastly, the vid ended very suddenly. I’d suggest a short recap/goodbye at the end.

    Again, overall, I thought it was very well done, easy to follow, and pleasant. Thanks.

  4. I followed your example and found that onValidate does not work with Tapestry 5. However onValidateForm does.

  5. Oh, and forgot to mention Excellent Demo! You didn’t miss a step and your presentation was good, even when you forgot to mark properties as private. Presenting errors definitely helps.

    Thanks for doing this.

Leave a Reply to Howard M. Lewis Ship Cancel reply

Your email address will not be published. Required fields are marked *