Results 1 to 2 of 2

Thread: FreeMarker Template Decorator

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Posts
    10

    Default FreeMarker Template Decorator

    Hi,

    I am using Spring MVC coupled with FreeMarker as viewing technology in a current web project and was looking for an easy way to decorate all of my content pages with a default layout.

    I had some previous experience with Tiles, but didn't like it because IMHO it's a little bit too invasive and too awkward to configure. Another option would have been to use SiteMesh, but again I didn't like the idea to setup an explicit servlet filter just to be able to decorate my views. Moreover, sharing of model data between the layout and the content pages would be rather complicated.

    Fortunately, Spring MVC came to my rescue. It was actually quite easy to extend the existing FreeMarkerViewResolver and FreeMarkerView classes, so that view templates will be automatically decorated with a common layout page.

    I thought it might be worthwhile to share the two classes (DecoratingFeeMarkerView and DecoratingFreeMarkerViewResolver - see attached zip). I've also included a sample spring config file to demonstrate how to configure the classes as well as a sample layout template and a sample content template page.

    Enjoy!
    Attached Files Attached Files

  2. #2
    Join Date
    May 2012
    Posts
    1

    Default

    thanks!I'm enjoying it!
    Last edited by xianglg; May 2nd, 2012 at 04:02 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •