Maxime ARNSTAMM
Maxime ARNSTAMM

Reputation: 5314

Advanced templating with jsp and sitemesh

Here's what i am trying to do:

I have a main template with header, menubar, body and footer. The body is replaced by the actual page called with the help of sitemesh like this:

<div class="main">
  <decorator:body />
</div>

Same for the title etc.

My problem is with the menubar: i would like to declare the content of the menubar in the actual page. The menus changes in every page, but i don't want to duplicate the layout of the menubar in every page.

My tools are JSP, Sitemesh and Spring MVC 3.

Is it possible? And if it is, how?

Upvotes: 2

Views: 2605

Answers (3)

robsf
robsf

Reputation: 1733

In a similar configuration of yours, I'm simply using a jsp include tag

<div class="mymenu">
    <jsp:include page="menu.jsp"/>
</div>

Upvotes: 0

Maxime ARNSTAMM
Maxime ARNSTAMM

Reputation: 5314

Here's how i did it :

template.jsp :

<div class="menubar" >
   <decorator:getProperty property="page.navig"></decorator:getProperty>
</div>

actualpage.jsp :

<body>
   <content tag="navig">
      my menu \o/
   </content>
...
</body>

Note : without the 'page.' it does not work.

Upvotes: 3

JB Nizet
JB Nizet

Reputation: 692151

I think you should use the page:applyDecorator tag. You would have a dedicated decorator for the menu bar, responsible for the layout of the menubar, and the contents of the menubar would be in the body of the tag, in every page.

I have not used it, but this tag seems to do exactly what you want.

Upvotes: 0

Related Questions