Search code examples
liferay-6freemarkerspring-portlet-mvc

Liferay portlet with freemarker and spring


I am developing simple portlet for liferay portal(v6.2) using spring portlet mvc(v3.2.9) with FreeMarker template engine(v2.3.14). I use portlet and aui taglibs to create pages

<#assign portlet=JspTaglibs["http://java.sun.com/portlet"]> 
<#assign aui=JspTaglibs["http://liferay.com/tld/aui"]>

Those tags works in most cases but I have problem with following code

<@aui.form action="${editPreferencesUrl}">
    <@aui.model-context bean="${myBean}" />
    <@aui.input name="name"  />
    <@aui.input name="surname" />
</@aui.form>

I get following exception

javax.portlet.PortletException: org.springframework.web.util.NestedServletException: View rendering failed; nested exception is freemarker.core.NonNumericalException: Error on line 8, column 11 in preferences.ftl
Expression aui.model is not numerical
Expression context is not numerical

I was following this tutorial http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Alloy+UI+Forms+(aui)/pop_up?_36_version=1.9

The problem is @aui.model-context definitely. How to use this tag in free marker?


Solution

  • Like <@aui['model-context'] bean=...>. (Because, foo.bar is equivalent with foo['bar'], and the thing after @ is just a generic FTL expression.)

    BTW, are those "${expression}"-s necessary? Do you have to convert to string there? Because otherwise you should just write action=editPreferencesUrl and such.