jquery

gist JS

Thursday, April 20, 2006

freemarker sitemesh body onload

So you've got a:
<body onload="doMyOnload();">

in your freemarker template, but
<body>
${body}

in the decorator blows this away...

The site mentions
<body onload="<decorator:getProperty name="body.onload" />">
but you're not using jsp because you've convinced yourself you're better than that.


So you eventually figure out...

<body ${page.property["body.onload"]}>

And you're all set again. Isn't that nice. 29 tabs died to bring you this information. Use it wisely.


UPDATE the commenter speaks the truth. I'd switched over at some point but never updated this.
<body onload="${page.properties["body.onload"]?default("")}">

1 comment:

Anonymous said...

I just came across this too, and I couldn't get your example to work exactly as-is.

However, this works for me:

<body onload="${page.properties["body.onload"]?default('')}">

It may also be good to check if there is an onload attribute rather than using the default to ''.