This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tiles definition xml or JSP

 
Aruna Srinivasan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

or

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

Example:

Say I have a template.jsp, such as

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

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

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

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

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

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

Thanks,
Aruna
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic