Ajaxified Body
You can read the Introduction to SiteMesh article if you're interested in learning more about SiteMesh's basic features. By default, SiteMesh decorates text/html responses and ignores any other content type (e.g. image/gif). It also contains an <excludes> configuration element that allows you to turn off decoration when a URL matches a certain pattern. For example, the following allows you to disable decoration when "ajax=true" is passed in the URL.
<excludes>
<pattern>**ajax=true</pattern>
</excludes>
To optimize the loading of an application so the common elements aren't loaded for each page, it should be possible to create an Ajaxified Body where the primary content area (PCA) of the site is loaded via Ajax rather than refreshing the whole page. The header, footer and navigation bar often stays the same from page-to-page, so it doesn't seem to make a whole lot of sense to load them each time the page loads. The image below shows the PCA (of an AppFuse Light application) as a grey square with a red border.
Matt Raible has been building web applications for most of his adult life. He started tinkering with the web before Netscape 1.0 was even released. For the last 11 years, Matt has helped companies adopt open source technologies (Spring, Hibernate, Apache, Struts, Tapestry, Grails) and use them effectively. Matt has been a speaker at many conferences worldwide, including ApacheCon, JavaZone, Colorado Software Summit, No Fluff Just Stuff, and a host of others.
Matt is a DZone MVB and is not an employee of DZone and has posted 45 posts at DZone. You can read more from them at their website.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)












Comments
Fernando Ortigosa replied on Mon, 2008/10/06 - 6:17am
here_he_is replied on Tue, 2008/10/07 - 10:44pm
Personally, I've found writing my own custom component enough for my needs. It's a little bit of Javascript to do a call to the server, and the server then returns a tag (to place the response) and the HTML fragment itself. HTML is then populated in the tag on the page using the .innerHTML methods.
It's simple enough to do and works well when what you really want to do most of the time is just change small fragments around on the page from a user request.