Dear Roland-from-last-week,
The normal ConfigDecoratorMapper does what you want. Since namespaces in
Struts look like a "path" in the URL, you can simply apply a decorator to the
pattern for the namespace. For example, in your decorators.xml, do:
<decorator name="yournamespace" page="yournamespace-decorator.ftl">
<pattern>/yournamespace/*</pattern>
</decorator>
There is no need for your templates to declare their decorator using the meta
tag and thus invoke the PageDecoratorMapper.
love,
alert roland
On Jun 28, 2011, at 3:44 PM, [email protected] wrote:
> I have two namespaces, "admin" and " (the default namespace). I'd like to
> re-use the same result template for both, but decorate them differently.
>
> My templates declare their decorator using the meta tag, like this: <meta
> name="decorator" content="admin" />
> Then, in decorators.xml, I have defined: <decorator name="admin"
> page="admin.ftl" />
>
> I'd like to generalize this to have one decorator per namespace, and remove
> the meta tag in my files. How can I get DecoratorMapper to be namespace
> aware? Should I write my own NamespaceDecoratorMapper extends
> AbstractDecoratorMapper? How would the DecoratorMapper get access to the
> ServletActionContext?
>
> Alternately, I could keep my current system and simply use <meta
> name="decorator" content="${namespace}" /> in my result templates, then
> implement my BaseAction's getNamespace as:
>
> String getNamespace() {
> return ServletActionContext.getActionMapping().getNamespace();
> }
>
> What do you guys think? Has anyone implemented namespace-specific sitemesh
> decorators before?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]