aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tiles definition xml or JSP" Watch "Tiles definition xml or JSP" New topic
Author

Tiles definition xml or JSP

Aruna Srinivasan
Greenhorn

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

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

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="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tiles definition xml or JSP
 
Similar Threads
nested tiles
Problem in rendering html tags in myfaces tiles
struts2 tiles problem
Tiles winding me up.
Problem in resolving an issue in Tiles