2011-03-16 12 views
9

sto cercando di fare qualcosa di simile: the layoutÈ possibile decorare più di una volta in Sitemesh?

Per tutte le richieste a/admin/* Ho bisogno della pagina da decorare utilizzando il decoratore B, ma anche che B decoratore deve essere incluso nel contenuto di un decoratore che è il layout principale dell'applicazione.

Come posso farlo con Sitemesh?

È possibile? O devo ripetere lo stesso layout da A nel decoratore B?

Grazie in anticipo

risposta

14

Per rispondere alla mia stessa domanda. Sì, è possibile:

Usando il mio esempio, questo è decoratrice b essere decorato da decoratore un.

<page:applyDecorator name="a"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
    <title>Decorator B</title> 
    <decorator:head/> 
</head> 
<body id="page-home"> 
    This is a test. 
</body> 
</html> 
</page:applyDecorator> 
+0

Questo metodo è ok. – imcaptor

0

Ecco l'esempio utilizzando freemarker:

<#assign decorator = JspTaglibs["http://www.opensymphony.com/sitemesh/decorator"]/> 
<#assign page = JspTaglibs["http://www.opensymphony.com/sitemesh/page"]/> 
<@page.applyDecorator name="a"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
    <title>Decorator B</title> 
    <@decorator.head/> 
</head> 
<body id="page-home"> 
    This is a test. 
</body> 
</html> 
</@page.applyDecorator> 
Problemi correlati