Sitemesh with multiple decorator files
I want multiple decorators as described here: https://github.com/sitemesh/sitemesh2 . I provide multiple decorators in decorators.xml, but the main decorator is applied to every file in my project. For example. my decorators look like this:
<decorators defaultdir="/WEB-INF/decorators">
<decorator name="main" page="main.jspx">
<pattern>/*</pattern>
</decorator>
<decorator name="other" page="other.jspx">
<pattern>/spring/other/*</pattern>
</decorator>
</decorators>
Both /spring/some/page.jspx
and /spring/other/page.jspx
are displayed as a template `main.jspx '.
What am I doing wrong?
source to share
I know the example documentation conflicts with this idea, but if you need to try something - try reordering your decorators like this:
<decorators defaultdir="/WEB-INF/decorators">
<decorator name="other" page="other.jspx">
<pattern>/spring/other/*</pattern>
</decorator>
<decorator name="main" page="main.jspx">
<pattern>/*</pattern>
</decorator>
</decorators>
From memory, I thought Sitemesh used the first matching decorator pattern and with the order you specified, which would always be the "main" decorator.
Use the following:
<decorators defaultdir="/WEB-INF/decorators">
<decorator name="main" page="main.jspx">
<pattern>/spring/main/*</pattern>
</decorator>
<decorator name="other" page="other.jspx">
<pattern>/spring/other/*</pattern>
</decorator>
</decorators>
and tell me if it worked.
source to share