This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Tiles definition xml or JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tiles definition xml or JSP" Watch "Tiles definition xml or JSP" New topic

Tiles definition xml or JSP

Aruna Srinivasan

Joined: May 10, 2005
Posts: 1
In our project we have decided to use tiles to control the layout. 2 ways we are contemplating are:

1. Use tiles.xml and provide the definition of the pages there based on template JSP pages


2. Use a different JSP as a definition for a template.


Say I have a template.jsp, such as

<div id="level1">
<div id="topBar">
<tiles:insert attribute="header" flush="false"/>
<div id="level2">
<tiles:insert attribute="body" flush="false"/>
Approach 1 will use a xml definition file as

<definition name="layout.example" path="/template.jsp" >
<put name="header" value="/common/header.jsp" />

<definition name="/page1.tiles" extends="layout.example" >
<put name="body" value="/page1.jsp" />

Approach 2 uses a JSP file (page1.jsp) such as

<%@ taglib uri="" prefix="tiles" %>
<tiles:insert definition="/template.jsp">
<tiles ut name="header" value="/common/header.jsp"/>
<tiles ut name="body" value="/page1.jsp"/>

I would like to know which of these approaches is preferrable in terms of code maintenance and performance.

alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
tiles-def centralizes all your templates definitions declaratively. you can define master templates and simply define areas to instert tiles and reuse the master template. this is the prefer way just as everything is declarative nowadays for simpler maintenance (look at validation and DynaActionForm in struts from v.1.0 to v.1.1).

-/a<br />certified slacker...yes, my last name is 'do' - <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Tiles definition xml or JSP
Similar Threads
struts2 tiles problem
nested tiles
Problem in rendering html tags in myfaces tiles
Problem in resolving an issue in Tiles
Tiles winding me up.