Dashboard > SiteMesh > Compare Sitemesh - Tiles
  SiteMesh Log In View a printable version of the current page.  
  Compare Sitemesh - Tiles
Added by Scott Farquhar, last edited by Mike Cannon-Brookes on Apr 19, 2004  (view change)
Labels: 
(None)

Tiles and Sitmesh are both page decoration tools, but they go about things very differently.

From my (limited) understanding, Tiles you have to 'push' everything into it. If you want a title - you need to specify it in tiles-def.xml. I'm not sure what Tiles gives you that you couldn't achieve with a big velocity template & a properties file to pull the value in from.

Sitemesh on the other hand, understands the HTML of the page you are decorating. So you just have to produce HTML as your raw input. You can view your pages with or without decorators, and they are still valid HTML files.

However, the distinction is that you can only have one decorator per page, rather than lots of 'tiles'. Mostly this fits with web design, as usually there is one rather large 'content' area, with some other navigation around it.

The other advantage is that your pages are almost completely decoupled from your decorators. These three URLs are exactly the same, aside from the decorators used:

If you want to do what you are after - you can achieve it with sitemesh. You can do your conditional 'put admin navigation on the admin page' either with different decorators, or with conditional logic inside a decorator.

You could even use Tiles inside your decorator (decorators as just JSP files) to do this logic.

The other advantage of sitemesh is that you can use it to decorate 'parts of pages'.

The code for this page looks like:

http://jira.opensymphony.com/secure/CreateIssue!default.jspa

<html>
<head>
    <title>Create Issue</title>
</head>

<body>
<page:applyDecorator name="jiraform">
  <page:param name="title">Create Issue</page:param>
  <page:param name="description"><b>Step 1 of 2</b>:
        Choose the project and issue type...</page:param>
  <page:param name="action">CreateIssue.jspa</page:param>
  <page:param name="submitName">Next &gt;&gt;</page:param>

  <ui:select label="'Project'" name="'pid'"
       list="allowedProjects" listKey="'long('id')'"
       listValue="'string('name')'" />
  <ui:select label="'Issue Type'" name="'issueType'"
       list="/constantsManager/issueTypes" listKey="'string('id')'"
       listValue="'string('name')'">
    <ui:param name="'helpURL'">issues</ui:param>
        <ui:param name="'helpURLFragment'">#IssueTypes</ui:param>
  </ui:select>
</page:applyDecorator>
</body>
</html>

That's it - the whole page. The 'jiraform' decorator decorates the form box, and the normal decorator decorates the whole page. Take a look at the source for the above to see how much extra is added.

Hey,
I just started looking at SiteMesh and it looks great, much simpler and more elegant for templating pages than Tiles, which I've been using so far (with Struts MVC).
Nevertheless there are few things about Tiles I'd like to add to the comparison. In case there is a possibility how to achieve similar things with SiteMesh, please let me know about it.

-Tiles can contain unlimited number of attributes (jsp pages, titles...), so you can push much more things into a template.
-The attributes can be also lists of jsp pages/values etc. e.g.
<definition name="left" path="/common/layouts/leftListLayout.jsp" >
<putList name="portlet_left_pane" >
<add value="portlet.title" />
<add value="page1.jsp" />
<add value="page2.jsp" />
<add value="portlet.footer" />
</putList>
<putList name="portlet_right_pane" >...
</definition>
-You can set a controller for a tile (java class), which can do various things, e.g. dynamicaly change the attributes/pages/content of lists in definitions. This can be used to create dynamic personalized portals.
It seems to me that while SiteMesh is definitely better solution for
templating/decorating only, on the other hand, Tiles provide more functionality usefull in scenarios such as portals.
All the best,
Mirek

Posted by RoadBug at Jan 26, 2006 04:49 | Permalink
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators