freeMarkerPortletPreferences has evaluated to null or missing

Jacek Koziel, modified 6 Years ago. New Member Posts: 3 Join Date: 4/23/18 Recent Posts
Hi,i have migrated a custom theme from Liferay 7.0 to Liferay 7.2. The theme deploys without any errors.
In the theme, in portal_normal.ftl i have  a runtime portlet (JournalContentPortlet  to display an article)

 <#assign topBarSection = journalArticleLocalService.getLatestArticleByUrlTitle(themeDisplay.getScopeGroupId(), "top-bar-section", 0)>
 <#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "borderless") />
        <#assign theme_groupID = htmlUtil.escape(theme_display.getCompanyGroupId()?string) />
        <#assign VOID = freeMarkerPortletPreferences.setValue("groupId", '${group_id}') />
        <#assign VOID = freeMarkerPortletPreferences.setValue("articleId", '${topBarSection.getArticleId()}') />
        <@liferay_portlet["runtime"]
        defaultPreferences="${freeMarkerPortletPreferences}"
        portletProviderAction=portletProviderAction.VIEW
        instanceId="topbarcontent"
        portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" />
        ${freeMarkerPortletPreferences.reset()}

Im using freeMarkerPortletPreferences to set the runtime portlet preferences.
Unfortunatelly i get an exception at the line  <#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "borderless") />
The following has evaluted to null or missing:
==> freeMarkerPortletPreferences.setValue [in template "mytheme_SERVLET_CONTEXT_/templates/portal_normal.ftl" at line 120, column 24]


It did work in the Liferay 7.0 CE. Now it seems like the freeMarkerPortletPreferences variable is null, so running a setter causes an exception. In portal-ext.properties i have:
freemarker.engine.restricted.classes=
freemarket.engine.restricted.variables=

Does anybody have any idea what might be the problem?
Im using some other freemarker variables also(like ServiceLocator to get a service reference) an they work fine.
Jacek Koziel, modified 6 Years ago. New Member Posts: 3 Join Date: 4/23/18 Recent Posts
i have downloaded the sources and in liferay 7.2, the methods: reset, setValue, setValues has been removed from TemplatePortletPreferences.
So in Liferay 7.2 you should use freeMarkerPortletPreferences .getProperties(propertiesMap) , where propertiesMap is Map<String,Object>
Jamie Sammons, modified 3 Years ago. New Member Post: 1 Join Date: 9/26/22 Recent Posts

Estoy migrando un tema a las 7.2 y llevo tiempo comprenderlo, se resuelve de la siguiente manera:

SOLUCION

<#assign

    freeMarkerPortletPreferences = freeMarkerPortletPreferences.getPreferences({

    "portletSetupPortletDecoratorId": "barebone",

    "groupId":theme_display.getCompanyGroupId()?string,,

    "articleId": ''

    })

/>

 

<@liferay_portlet["runtime"]

    defaultPreferences="${freeMarkerPortletPreferences}"

    portletProviderAction=portletProviderAction.VIEW

    instanceId="modalfacebookdos"

    portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet"

/>

 

Metodo RESET ya no es necesario para la version 7.2