Friday, August 04, 2006

SiteMesh I Likes

SiteMesh is one of those tools that has made me stop and re-evaluate how I write web applications (a paradigm shift if you like). It is basically a servlet filter that allows you to decorate web pages with header, footer and navigational adornments after your application produces the output. I saw it described somewhere as AOP for the web. Something about the way that SiteMesh works feels very right to me at the moment. SiteMesh focuses the mind on creating applications in such a way that they become a very good fit with the direction where Web application development are currently heading (even if you're not actually planning to use SiteMesh in those applications).

SiteMesh is not Tiles

I have, on some limited occasions, used Tiles with Struts applications. There is something about Tiles that seems over elaborate. I'm sure there are numerous cases where Tiles does things that you can't do with SiteMesh. However, I like SiteMesh precisely because it is such a simple idea.

Separating presentation from content

What is really nice about SiteMesh is that it really focuses the mind on completely separating presentation from content (even the navigational aspects). This seems all the more relevant in the current climate of Web 2.0 and portlet environments. Web 2.0/AJAX style applications often devolve user interface elements to the client side. Portlets also advocate the final responsibility for user interface to the portal.

Context Specific Rendering

I like the idea that based on the contents of a cookie the same application could be rendered entirely differently. I could have university department specific interfaces without the need to actually change the underlying application once it has been written to accommodate SiteMesh decoration.

To use the description often quoted to me about CMS systems, with SiteMesh the content becomes the sandwich filling with the bread of the sandwich (headers, footers, navigation) added via SiteMesh.

Using SiteMesh with Struts Bridge Portlets

What I also like is the idea that since it works via a filter, I can take advantage of this in the portlet environment. Struts Bridge applications are Struts applications that can run as standalone applications and simultaneously as portlets. Essentially, if I wrote a Struts Bridge based application then using SiteMesh it could have header, footer and navigational elements in the "standalone" view and without the need to change anything these would disappear in the portlet rendering (this is because portlets are not effected by servlet filters).

Passing "Where Am I?" content through to SiteMesh

In order for SiteMesh to add context specific navigation it needs to know something about where it has been invoked. Since SiteMesh works as a servlet filter, it can only extract this information from some aspect of the page. SiteMesh has access to a pages' URL, URL parameters and cookies, so it can use these as sources of information. SiteMesh decorators can also access information from the contents of a HTML page (although the specifics elements that you can access appear deliberately quite limited). SiteMesh can access the <head>, any <meta> elements specified in the <head> and the <body> content. I think it would pollute and overcomplicate SiteMesh if it had full HTML DOM browsing facilities, restricting it to a limited set of information makes it simpler and in my view better. Therefore if you add a meta data element to the header of the content page this can be used to render the context aware navigation (all this machine readable meta data sounds a bit semantic web-ish, doesn't it?). So with a bit of effort you can create context aware navigation menus. This got me thinking about how best to separate breadcrumb (homeward path) style navigation, I will talk more about this in my next entry.

See also:
  1. Dynamic Navigation using SiteMesh
  2. Dependency Injection with SiteMesh


Mark McLaren said...

there is one small problem with sitemesh, Although designed to be very fast in big pages it may be give a small CPU impact since it parses the whole page. Not as elegant and a little more work, but jsp tags may be used instead of sitemesh, tough it requires adding some lines of code to each page i assume..
Note: Comment imported. Original by Anonymous at 2006-08-04 16:06

madin said...

Set on his signature 100mm heel,replica shoes Christian Louboutin’s replica flats Platinana courts are guaranteed to lengthen your legs to supermodel standards. Rendered in a combination of patent and matte leather, the ankle strap curves around the front to join the sharp, pointed toe. They’re finished, of course, with the iconic red lacquered sole. These will pair just as well with denim as with a cocktail dress.

madin said...

Created in 1993, replica shoes Christian Louboutin’s signature red-bottom heels remain the fashion world’s most stylish stilettos. replica christian louboutin Level up your shoe collection for less with unbeatable Christian Louboutin sales, where you’ll find alluring Louboutin heels and unique Louboutin shoes in your perfect size.

madin said...

cheap Soccer Jerseys is the best soccer jerseys wholesale tammy abraham Jerseys Buy the cheap soccer jerseys, soccer shirts, soccer kits, training kits with wholesale price.