Alternative for deprecated FreeMarker keywords

January 19, 2010

Some alternative for deprecated commonly used freemarker keywords


?? is the alternative of exists?
for example,
<#if something?exists>
can be written as
<#if something??>


Here are some example

Keywords Alternative
?exists ??
?if_exists !
someThing?default(anotherThing) someThing!(anotherThing)


How to use int as the key of a Map to display in FreeMarker

July 23, 2008

Map (java.util.Map) in java is used to keep a key value pair. Though map.put consider both key and value as object. But if anyone want to send a map with a key as int for view in FreeMarker (*.ftl file) it can not resolve the value of the map by ${map[key]}. Though your java code works fine with int key but FreeMarker generate error message in following way,


Exception:
Expected number, sequence, or string. messageMap evaluated instead to freemarker.template.SimpleHash on line XX,


The easiest way to get out of this error is just to make the key to string by using the command .toSting() in java code. This works fine with *.flt.

By: Md. Shahjalal


Follow

Get every new post delivered to your Inbox.