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("")}">

Tuesday, April 11, 2006

Freemarker Booleans in Beans

Note to self, making model beans that you want to use in Freemarker? Make sure them boolean's are java.lang.Boolean (in the docs) and change your getters from isMyBool() to getMyBool() (not in the docs), otherwise it's headscratching time trying to figure out why it can't find your junk.


Expression command.myBooleanis undefined on line 262, column 6 in WEB-INF/freemarker/verify.ftl.
The problematic instruction:
----------
==> if command.myBoolean [on line 262, column 1 in WEB-INF/freemarker/verifyStudy.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression command.myBoolean is undefined on line 262, column 6 in WEB-INF/freemarker/verify.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.isTrue(Expression.java:145)



Most important though is to get on junit testing your freemarker views. Getting this all set was such a lovely vindication of sorts for me. Nice tests all the way from the DB to the web? Without this testing the above would've been misery. Now? I just feel pretty much invincible.