3

I want multiple decorators, as documented here: https://github.com/sitemesh/sitemesh2. I provide multiple decorators in decorators.xml but the main decorator gets applied to every file in my project. E.g. my decorators looks 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>

And both /spring/some/page.jspx and /spring/other/page.jspx both render with the `main.jspx' template.

What am I doing wrong?

Kevin
  • 24,871
  • 19
  • 102
  • 158

2 Answers2

4

I know the documentation example contradicts this idea, but if you need something to try -- try re-ordering your decorators like so:

<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've specified that would always be the "main" decorator.

0

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.

GingerHead
  • 8,130
  • 15
  • 59
  • 93
  • 1
    that didn't work. actually I've tried a bunch of things and the only thing that works (for any template) is `/*` or `/context*`. So for example any pattern like `/context/x/*` doesn't get applied. – Kevin Apr 08 '12 at 00:20