How do I call java methods on an object from a FreeMarker template?

FreeMarker allows invoking methods that were made available through the model from within expressions. Assuming your object has been exposed as myBean you can invoke the method as follows: <#list myBean.getunits(“myType”) as unit> do stuff with ${unit} </#list> You don’t have to use <#list>, of course, it’s just there as an example since your method … Read more

Use ternary operator in freemarker?

If you’re using freemarker 2.3.23 or newer, you can use the then built-in: <a href=”https://stackoverflow.com/questions/17539686/${a?then(“a.htm’,’b.html’)}” target=”${openTarget}”> If you’re using an older version of freemarker, you can use instead the string built-in: <a href=”https://stackoverflow.com/questions/17539686/${a?string(“a.htm’,’b.html’)}” target=”${openTarget}”> When applied to a boolean, the string built-in will act as a ternary operator.

Velocity vs. FreeMarker [closed]

The goals for the projects are different. Velocity’s goal is to keep templates as simple as possible, to help maintain a segregation between logic and presentation, so you don’t slide down the slippery slope of sticking code in templates. Sometimes this is the right thing. Of course, sometimes being able to wire complicated logic directly … Read more

Why would I use a templating engine? jsp include and jstl vs tiles, freemarker, velocity, sitemesh

A few arguments for Velocity (I haven’t used Freemarker): Potential to re-use templates outside of a web context, such as in sending emails Velocity’s template language syntax is far simpler than JSP EL or tag libraries Strict separation of view logic from any other sort of logic – no possible option to drop down to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)