Foren

Freemarker: method Create from PortletURLFactoryUtil

Luis Onieva Marenco, geändert vor 6 Jahren.

Freemarker: method Create from PortletURLFactoryUtil

New Member Beitrag: 1 Beitrittsdatum: 21.04.14 Neueste Beiträge
Hi there,

I´m trying to build the url of a portlet using this code:

<#assign portletURL = portletURLFactoryUtil.create(request,"MyPortletId",themeDisplay['plid'],"RENDER_PHASE")/>


Got the themeDisplay object as it follows:

<#assign themeDisplay = request['theme-display'] />


However, when the template is on the run, I get an error:

No signature of method create matches the arguments

Could you help me guessing what is wrong with the arguments? :S

Thanks in advance,
Luis
thumbnail
Andrew Jardine, geändert vor 6 Jahren.

RE: Freemarker: method Create from PortletURLFactoryUtil

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Luis,

This one has come up several times in the forums. I am assuming that you are doing this in a WCM template? in which case the request object is not a REAL request object. If you ouput the value of the themeDisplay that you think you have in your template, you'll probably end up with a "blank" because you don't really have it. To get it, you need an actual request object. One of the work arounds you will find is to use the ServiceContextThreadLocal in your template. From there you can grab the request, and then the theme. Something like this --


    <assign serviceContextThreadLocal="portal.getClass().forName(&quot;com.liferay.portal.service.ServiceContextThreadLocal&quot;).getServiceContext())" />
    <assign httprequest="serviceContextThreadLocal.getRequest()/">
    <assign themedisplay="httpRequest.getAttribute(&quot;THEME_DISPLAY&quot;)/">
</assign></assign>


.. or something along those lines, I'm typing that up from memory.