jspstruts2sitemesh

Sitemesh 2.4.2: How to use decorators other than body decorator


I am using struts2-archetype-starter Maven template to create Struts2 webapp. Though, I used Struts2 before, I am new to Sitemesh. I have one adminTemplate.jsp in my decorator folder, containing one <decorator:body /> tag.

As we know, body is not the only thing we might want to customize, I need some custom scripts in my page. <decorator:body /> comes above footer (not very good place your scripts).

I also tried to refer to the docs provided by Sitemesh, here:

http://wiki.sitemesh.org/display/sitemesh/Passing+Additional+Elements+to+the+Decorator

But, unfortunately, the page is not having any text at all.

How can I achieve the same? I'm seeking some good docs as well.


Solution

  • you can insert the head placeholder in the adminTemplate.jsp

    <head>
      <title>
        <decorator:title/>
      </title>
      ...
      ...
      <decorator:head/>
    </head>
    

    then custom scriptes in your pages.

    <head>
      <title>
        page1
      </title>
      <script>
        ....
      </script>
    </head>