0
votes

I'm using a freemarker template to display web contents listed in an asset publisher.

In the template I'm trying to assign the portlet-namespace in order to use some asset features (like printing the entry) like this

<#attempt>
  <#assign namespace = request["portlet-namespace"]>
  <#recover>
  <#assign namespace = 'undefined'>
</#attempt>

So, the print button is holding te code below

<a href="javascript:${namespace}printPage_0();" title='Print'>

printPage is the method used in liferay asset publisher code in asset_print.jspf

Well, everything is working fine: when inspecting the page in a browser, I verified that the namespace has been calculated and assigned to namespace variable as well (and no error displayed in UI). However, liferay portal logs the following each time a user tries to see the whole web content (ie. clicks on read more) from the asset publisher

Expression request["portlet-namespace"] is undefined on line

Anyone has seen this problem ? Is there another way to get the portlet-namespace in a freemarker template ?

1

1 Answers

1
votes

#attempt/#recover is not for recovering from normal situations, and by default it logs the error when it recovers (so that the operators will be alerted). You should instead use the exp!default operator:

<#assign namespace = request["portlet-namespace"]!'undefined'>

(Though I'm not sure why printing undefinedprintPage_0(); makes sense, but that's a different issue.)