File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts Templates vs. Tiles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Templates vs. Tiles" Watch "Struts Templates vs. Tiles" New topic

Struts Templates vs. Tiles

Michael McElwee
Ranch Hand

Joined: Nov 06, 2001
Posts: 30
I am using Struts 1.1 for a current web project. To further break down the View into reusable, manageable pieces I am using Struts Templates, which I have found that I like a lot. Recently, I read a little bit about Struts-Tiles, which appears to perform the same thing as Struts-Templates. Which is the preferred approach, or is it just a matter of personal preference? Is this covered in the Author's new book?

SCJP2<br />IBM Certified Solution Developer<br />MCSD
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Struts In Action has pretty good coverage of Tiles. I believe it was a full chapter, but I don't have the book in front of me right now.

Matthew Phillips
Michael McElwee
Ranch Hand

Joined: Nov 06, 2001
Posts: 30
Does it compare/contrast Tiles with Templates? I guess my concern is that I have already completed a fair amount of my project using Templates, so switching to Tiles could involve significant work. I am not opposed to that if there is some large benefit. Right now, they (Templates and Tiles) sound to me like different, equally-acceptable solutions. I have gotten decent with Struts, but I definitely do not consider myself an expert on this.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Michael,
Struts Tiles is a newer and more comprehensive approach to add Layout Management functionalities to Struts. It includes all the Struts Template tags.
To switch from Struts Templates to Struts Tiles all you have to do is to change the *.tld like this:

There is no need to change the prefix from templates to tiles.
Besides that the Tiles Framework goes much further: With 'Tiles Definitions' you can configure the whole Layout-Management with a XML file. You can catch the whole Screenflow of your project by just taking a glimpse in this XML file. You can even define and extend Tiles Definitions. It's fun and worth to give a try.
Berny Woehrlin
Ted Husted
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
As Bernie pointed out, Tiles is specifically designed to be backwardly-compatible with the Template library, so you should not have any trouble migrating.
Also, the Template library will be deprecated in the next iteration of Struts 1.1, if that counts for anything.
HTH, Ted.

<a href="" target="_blank" rel="nofollow">Struts in Action</a>
I agree. Here's the link:
subject: Struts Templates vs. Tiles
It's not a secret anymore!