Sitemesh + WebWork2 + FreeMarker

"Richard HALLIER" <[email protected]>
Newsgroups gmane.comp.web.sitemesh.general
Message-ID <[email protected]>
Hi all,

With the latest sitemesh cvs snapshot, I've added a support for Freemaker
decorators, with exactly the same context attributes than for the Velocity
decorators :
$title
$head
$body
$base
$page

Freemaker decorators haven't any dependencies from WebWork. But, you CAN use
EVERY ww2 tags inside freemarker templates (decorators or includes) with a
remaining stack behind (eg last action pushed onto the stack)

Example of freemarker decorator :

<#include "/includes/decorators/header.ftl">
    <h2>${title}</h2>
    ${head}
    <img src="${base}/images/logo.gif" border="0">
    <td valign="top" class="body">
        <div class="header">
            <span class="pagetitle">${title}</span>
        </div>
        ${body}
    </td>
<#include "/includes/decorators/footer.ftl">

Example of header.ftl:

<#assign ww=JspTaglibs["/WEB-INF/lib/webwork.tld"] />

<table cellspacing="0" cellpadding="4" width="100%" border="0"
bgcolor="#003366">
<tr>
    <td height="30" valign="top" width="5%" nowrap><img
src="${base}/images/logo.gif"></td>
    <td valign="bottom" width="65%" nowrap style="color:white;"> Application
v<@ww.property value="@com.uniclick.afbah.Constants@VERSION"/> </td>
    <td valign="bottom" align="right" width="30%" nowrap
style="color:white;">
        <@ww.property value="#session['com.uniclick.user'].longName"/>
        <br>
    	<a href="logout.action" style="color:white;">Logout</a><br>
    <!--	<a href="?printable=true" style="color:white;"
target="_blank">Printable</a> -->
    </td>
</tr>
</table>

<@ww.component template="menu.vm">
	<@ww.param name="menuSection" value="menuSection"/>   --> Read menuSection
from the WW2 stack
</@ww.component>

If you find it interesting, I would share my code.
My 2 cents.

Richard HALLIER
Chef de projet
[email protected]
01.40.12.41.52
www.uniclick.org
UNICLICK




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.