Michael Jouravlev wrote:

So, the question I am asking: what are the real benefits of using
Tiles if I use JSP includes + XHTML/CSS for layout/styling? Can most
of Tiles features be implemented with XHTML/CSS?

I guess some of it comes to a personal preference in regard to the dynamic content stuff that I didn't see you mention (or I read over your post too quickly).

For example what about things where your "header" section needs a title to display in the html, or what if you quickly want to change around what pages get 'injected' (for lack of a better word) with a particular div? To accomplish this without something like tiles, you 1) have to set up certain things in the request in your Action before you go to your page and 2) you have to have jstl logic to decide whether or not to display the information. Personally I find it much cleaner to have this stuff defined in one place. So for example, lets look at your master layout...

<jsp:include page="masterLayout.jsp">
<div class="content">
//all your content
</div>

masterlayout.jsp
----------------
<div class="header"><jsp:include page="header.jsp"/></div>
<div class="footer"><jsp:include page="footer.jsp"/></div>

header.jsp
----------
SOME COOL LOGO

{ Dynamic "MY SUPER TITLE" }

SOME OTHER LOGO
more other images
-------------------

Now in the above, how are you going to get your title into this header jsp? The only way I know of is that you'd have to set it up ahead of time in your action. What if someone decides that title needs to change? Personally I'd rather find all the titles in one place (tiles-definitions.xml) than have to find what Action it it is in and where in the Action you set it up.

Actually tiles just saved me a lot of time in a project I'm working on where each of the pages belongs to a certain "tab section" For example, 'post' is a link on the menu bar which is part of the "notification tab" section. Because the business requirements changed so much laying out this stuff was so easy as the powers-that-be changed their mind about what should be part of what tab ragion. Since you can extend layouts, it was a quick change to extend a different tab-layout in the tiles-definitions.

Also, another thing I like is when I want to change the layout of a page very quickly. For example, I often have a "popup" layout (doesn't contain the header and footer and other decoration). If I want to quickly change the resulting page to use this layout, it's a 1 second change in my tiles-definitions. This becomes even more clean when sometimes this page has the popup layout but other times the page is used with the normal layout. Using Tiles you can set up a definition as yourpage.popup and yourpage.normal. Now, in your struts-config you might have action mappings that foward to "popup" and "normal" - the content never changes - only the layout. To me this is more clean than having JSTL logic in the JSP page to decide whether or not to display certain things. At any given time I can quickly change my mind and it's super easy... I simply modify one definition file instead of stripping out or putting back in JSTL logic to hide or show sections.

The other thing is that I'm still not convinced of the magic and wonders of css for layout. Personally to me it's often black magic voodoo. Sure, I'm sure some will say it's easy ...bla blah... BS I say. Complex layouts with css is ANYTHING but easy or intuitive. Sure for simple stuff it's fine, but I'll be willing to race almost any average css user in designing some complex layouts. They can use only css and divs. I can use tables. I bet you I'll be done much faster and it'll work in all browsers and it will be easy to understand (ok yes it will 'look' more cluttered, but it'll still be intuitive.) Ok done ranting about css positioning:)

Lastly, I think sitemesh is great, but I've haven't checked in a while to see if they still buffer everything before outputting the displaying. This was a huge performance hit in my last application since we had some huge (yes, arguably, too large) reporting jsps. Last time I used Sitemesh, sitemesh looked like it still had to hold everything in a buffer before decorating. You can imagine the memory problem that could occur for some very large jsps. If Sitemesh fixed this one problem, I'd use it over Tiles.

PS: when you mention:

Michael>>>>>
<%@ taglib uri="http://struts.apache.org/tags-tiles"; prefix="tiles" %>
<tiles:insert template="layout.jsp">
  <tiles:put name="title"  value="This is the title." />
  <tiles:put name="header" value="header.jsp" />
  <tiles:put name="body"   value="body.jsp" />
</tiles:insert>

I still have to specify all these <tiles:put> tags that refer to
particular header/footer files (Definition solves that, see below).
<<<< /michael

The "all these <tiles:put>" things in the above is only true for things that 'change' like the body.jsp and the title. Probably things like the header and footer would be part of the main.layout which you would be extending in your definition. (You typically set up a few layouts and all your pages then extend the ones they need.)

And also remember you still have to deal with getting a dynamic title into certain sections. You often can't always have it be in your main content page so it somehow has to become part of your header section (imagine the case I mentioned where you want to show a title between certain header images.. which is quite common.)


--
Rick


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to