Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: freeMarkerPortletPreferences has evaluated to null or missing
Hi,i have migrated a custom theme from Liferay 7.1 to Liferay 7.4.
The theme deploys without any errors.
In the theme, in
portal_normal.ftl i have a runtime portlet (JournalContentPortlet to
display an article)
<#attempt>
<!--Al parecer no existe freeMarkerPortletPreferences en 7.4-->
<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") />
<#assign VOID = freeMarkerPortletPreferences.setValue("showListed", "false") />
<#assign VOID = freeMarkerPortletPreferences.setValue("targetPortletId", "") />
<script>
console.log(${freeMarkerPortletPreferences})
</script>
<div class="col-11">
<@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
portletName="gsearchminiportlet"
/>
</div>
<#assign VOID = freeMarkerPortletPreferences.reset() />
<div class="col-1 close-search-button-wrapper">
<@liferay_aui["icon"] id="close-search-button" image="times" data={"show-id": "body"} markupView="lexicon" cssClass="neo-hover pull-right" />
</div>
<#recover>
<!-- Failed to load gsearch_search.ftl -->
</#attempt>
${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/gsearch_search" at
line 3, column 25]
Does anybody have any idea what might be the problem?
From a quick check, it looks like that API has changed dramatically. Your best and easiest bet might be to use the new standard "Master Page" to embed portlets on each page, instead of editing theme-side template code.
What have I done in my quick check?
grep -r "freeMarkerPortletPreferences" $SRC
which reveals a hit in
FreeMarkerTemplateContextHelper.java
This line refers to TemplatePortletPreferences,
which doesn't have any setValue method.
Following that path (specifically in FreeMarkerTemplateContextHelper), you might find a replacement option (e.g. as used in site-initializers), but my actual recommendation is to change your implementation and utilize Master Pages.
Yes, in 7.4 the syntax for embedding a portlet has changed... Try looking in the 7.4 themes for examples of the new syntax...
Powered by Liferay™