Monday, January 17, 2011

Tapestry Introduction

Tapestry5 represents the current trend in web frameworks to move the paradigm of programming from request response processing to more object oriented and event driven programming.Tapestry promotes a pure html based web application development so that role of web designers and programmers is better managed.

Before moving further download the stable version of 5.0.x of Tapestry from

Make a web application project in your Ide. If you are on eclipse you can make a Dynamic Web Project.Bring the libs available inside tapestry download. All the libs are more than required but at the moment let's go ahead with it.

Now open your web.xml and modify it as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=""
    xmlns="" xmlns:web=""
    id="WebApp_ID" version="2.5">
            This will tell where to look for tapestry pages

Tapesty register s filter and traps all the request. Also tells tapestry to where to look for component Java files. Now put a Index.tml file inside WebContent (The context root if you are on other than eclipse).

<html xmlns:t="">
        <title>Tapestry tutorial</title>
        <h1>Tapestry tutorial</h1>
        <p> Welcome to Tapestry Tutorial </p>
        <p> ${message} </p>

Note that it's a simple but well formed html. The only dynamic part is $message which is resolved by looking into the components file. The component file should be named as in this case. Index comes from the Index.tml file name after stripping tml. The java file has to put in the (from web.xml) location after putting a subpackage pages. So the whole package in this case where will go is com.oyejava.tapestry.pages


package com.oyejava.tapestry.pages;

public class Index {
    public String getMessage(){
        return "Hello Tapestry";

Deploy the application in your container and hit the application at  http://<container url>/<context>

No comments:

Post a Comment