Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Master the Tiles Framework

Rick Hightower enjoys working with Java technology, Ant, Struts, the IBM Emerging Technologies Toolkit (ETTK), and XDoclet. Rick currently serves as the CTO of ArcMind Inc., a mentoring, consulting, and training company focusing on enterprise development. Rick, a regular IBM developerWorks contributor, has written more than 10 tutorials ranging from EJB (Enterprise JavaBeans) technology to Web services to XDoclet.

While working at eBlox, Rick and the eBlox team used Struts to build two frameworks and an ASP (application service provider) for online e-commerce stores. They started using Struts long before the 1.0 release. Rick recently helped put together a well-received course for Trivera Technologies on Struts that runs on Tomcat, Resin EE, WebSphere Studio Application Developer, and others.

Rick co-authored Mastering Struts, 2nd edition with James Goodwill (Wrox Press). Rick also co-wrote Java Tools for Extreme Programming (John Wiley & Sons, 2001), the best-selling software development book on Amazon.com for three months in 2002. It covers applying Ant, JUnit, Cactus, and more to J2EE (Java 2 Platform, Enterprise Edition) development. Rick also contributed two chapters to Mastering Tomcat Development (John Wiley & Sons, 2002), as well as many other publications.

Rick spoke at the 2003 JavaOne Developers Conference on EJB CMP/CMR and XDoclet, and at TheServerSide.com Software Symposium on J2EE development with XDoclet. Additionally, Rick has spoken at JDJEdge and WebServicesEdge. Moreover, Rick spoke about advanced Struts topics at the Complete Programmer Network software symposiums (in six different cities across the US).

When not traveling around the country teaching the Trivera Struts course, speaking at conferences about Struts, or doing Struts consulting, Rick enjoys drinking coffee at an all-night coffee shop, writing about Struts and other topics, and writing about himself in the third person.

Summary:  This tutorial guides you through the process of using the Tiles framework to build site layouts and visual components. You will begin with the basics of the Tiles framework, then move on to more advanced topics

Date:  01 Dec 2003
Level:  Introductory PDF:  A4 and Letter (108 KB | 37 pages)Get Adobe® Reader®

Activity:  14309 views
Comments:  

Getting started

What is this tutorial about?

This tutorial describes how to use the Tiles framework to create reusable presentation components. (At its creation, the Tiles framework was originally called Components. The name was changed because "components" means too many different things, but the spirit of the original name remains.) Beyond site layouts, however, you can do much more with tiles. You can, for example, compartmentalize your presentation tier to better reuse layouts, HTML, and other visual components.

This tutorial strives to impart the basics of using the Tiles framework, then takes your knowledge up a notch. By the time you finish, you will be able to use the more advanced Tiles features to create reusable components.

Note: Throughout this tutorial, the terms tile and page are used interchangeably because any Web resource can be a tile. A tile layout represents a special type of tile you can use to place other tiles within it. A tile layout can be used as a tile in another tile layout.

Getting down to specifics, this tutorial:

  • Defines the Tiles framework and architecture.

  • Covers the Tiles architecture and how it integrates with Struts.

  • Clarifies key Tiles concepts.

  • Demonstrates how to build and use a tile layout as a site template.

  • Demonstrates how to use tile definitions both in XML and JavaServer Pages (JSP) code.

  • Defines tile scope and how to move objects in and out of tile scope.

  • Works with attribute lists.

  • Shows how to nest tiles.

  • Demonstrates how to build and use a tile layout as a small visual component.

  • Shows how to subclass a definition.

  • Creates a controller for a tile.

  • Demonstrates using a tile as an ActionForward.

Who should take this tutorial?

If you find yourself writing the same three lines of JSP code on every page, or you want to define complex template layouts easily, then you will benefit from this tutorial.

This tutorial assumes you have a solid understanding of Java programming, MVC (Model-View-Controller), Model 2, and JSP technology. While a good Struts background lets you get the most out of this tutorial, if you're adept at JSP programming, you should be able to follow most of what is going on.


Software requirements and code installation

To complete this tutorial, you will need:

  • A 1.1, 1.2, or 2.0 JSP-compliant servlet/JSP container. Apache Tomcat 3.x or higher is an excellent choice. Note: The tutorial's examples were written with a JSP 1.2-compliant container.

  • The Tiles framework. You can get the framework as part of the Struts 1.1 download or standalone from the Tiles Web site.

  • The source code. I've supplied two versions: one with jar files and one without jar files for those of us who are bandwidth impaired. Struts ships with a blank war file, struts-blank.war (under the webapps directory), which illustrates which configuration files and jar files you need, and where you typically put them. You'll use the same structure for the example code.

See Resources for information on these materials and additional resources.

1 of 10 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=132387
TutorialTitle=Master the Tiles Framework
publish-date=12012003
author1-email=rhightower@arc-mind.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).