I am trying to decorate a page with multiple decorators using sitemesh 3. The problem occurs when I add more pages, some of the pages gets decorated by another decorator leading to not properly decorated page.
Here is what I am trying to do:
/
and /login
with 2 decorators/welcome
with 2 different decoratorsThe sitemesh3.xml
look like this so far:
<?xml version="1.0" encoding="UTF-8"?>
<sitemesh>
<mapping>
<path>/</path>
<decorator>/decorator1.jsp</decorator>
<decorator>/decorator1-2.jsp</decorator>
</mapping>
<mapping>
<path>/login</path>
<decorator>/decorator1.jsp</decorator>
<decorator>/decorator1-2.jsp</decorator>
</mapping>
<mapping>
<path>/welcome</path>
<decorator>/decorator2.jsp</decorator>
<decorator>/decorator2-2.jsp</decorator>
</mapping>
</sitemesh>
The problem is that /welcome
gets decorated by decorator1
and decorator1-2
Can someone explain what did I missed here?
BTW, can I use multiple <path>
inside mapping to map multiple locations on one or more decorators or each path must be declared separately.
I know that I can use /*
to map all pages but what if I want something like:
<mapping>
<path>/admin/*</path>
<path>/manage/*</path>
<path>/secured/admin/*</path>
<decorator>decorator.jsp</decorator>
</mapping>
For your second question, the answer is YES. You can add multiple <path>
in <mapping>
, all paths will be decorated.
Back to your first question, if you decorate / or /* with some decorators, they will be applied all page. This means, if you want specifically decorate pages, please do NOT use / or /*. Below configurations come from my current project.
<mapping path="/*" decorator="/WEB-INF/decorators/menu.ftl"/>
<mapping>
<path >/catalog/*</path>
<path >/attribute/*</path>
<decorator>/WEB-INF/decorators/product_menu.ftl</decorator>
<decorator>/WEB-INF/decorators/menu.ftl</decorator>
</mapping>
<mapping>
<path >/member/comment*</path>
<decorator>/WEB-INF/decorators/comment_menu.ftl</decorator>
<decorator>/WEB-INF/decorators/menu.ftl</decorator>
</mapping>
As you can see, all pages are decorated by menu.ftl, and we also have some specific decorator for other pages.