<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Use attributes without renderRequest in a FreemarkerPortlet</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121678664" />
  <subtitle>Use attributes without renderRequest in a FreemarkerPortlet</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121678664</id>
  <updated>2026-04-08T00:39:06Z</updated>
  <dc:date>2026-04-08T00:39:06Z</dc:date>
  <entry>
    <title>RE: RE: Use attributes without renderRequest in a FreemarkerPortlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121684319" />
    <author>
      <name>Adrián Pol</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121684319</id>
    <updated>2023-03-31T14:51:15Z</updated>
    <published>2023-03-31T09:04:08Z</published>
    <summary type="html">&lt;p&gt;Good David, thanks for your answer, we are using a portlet for
  Liferay 7.3 but we have modified some things:&lt;br /&gt; - We have changed
  the MVCPortlet to FreeMarkerPortlet.&lt;br /&gt; - We have modified the bnd
  to integrate the tlds.&lt;/p&gt;
&lt;p&gt;In short, we have replicated a little bit the portlet of this Blade
  example.&lt;br /&gt; https://github.com/liferay/liferay-blade-samples/tree/master/liferay-workspace/apps/freemarker-portlet&lt;/p&gt;
&lt;p&gt;I put here a little code to demonstrate how we have the module&lt;/p&gt;
&lt;p&gt;Portlet:&lt;/p&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td id="LC44"&gt;public class BladeFreeMarkerPortlet extends
        FreeMarkerPortlet {&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;
      &lt;td id="L45"&gt; &lt;/td&gt;&lt;td id="LC45"&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;MVCRender:&lt;/p&gt;
&lt;p&gt;//@formatter:off&lt;br /&gt; @Component(&lt;br /&gt;         immediate =
  true, &lt;br /&gt;         property = { &lt;br /&gt;                
  &amp;quot;javax.portlet.name=&amp;quot; +
  BladeFreeMarkerPortlet.PORTLETID, &lt;br /&gt;                
  &amp;quot;mvc.command.name=/&amp;quot;,&lt;br /&gt;                
  &amp;quot;mvc.command.name=/portlet_freemarker/view&amp;quot; &lt;br /&gt;          
        }, &lt;br /&gt;         service = MVCRenderCommand.class&lt;br /&gt;        
  )&lt;br /&gt; //@formatter:on&lt;br /&gt; public class
  FreemarkerPortletViewMVCRenderCommand implements MVCRenderCommand {&lt;/p&gt;
&lt;p&gt;    @Override&lt;br /&gt;     public String render(RenderRequest
  renderRequest, RenderResponse renderResponse) throws PortletException
  {&lt;br /&gt;         final ThemeDisplay themeDisplay = (ThemeDisplay)
  renderRequest.getAttribute(WebKeys.THEME_DISPLAY);&lt;br /&gt;       
   renderRequest.setAttribute(&amp;quot;exampleVar&amp;quot;, &amp;quot;Emample View
  Var&amp;quot;);&lt;br /&gt;         return &amp;quot;templates/view.ftl&amp;quot;;&lt;br /&gt;
      }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;View:&lt;/p&gt;
&lt;p&gt;&amp;lt;#include &amp;quot;init.ftl&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;h1&amp;gt;Freemarker Portlet&amp;lt;/h1&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;p&amp;gt;&lt;br /&gt;     &amp;lt;b class=&amp;quot;redBackground&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;@liferay_ui[&amp;quot;message&amp;quot;]
  key=&amp;quot;example.text.caption&amp;quot; /&amp;gt;&lt;br /&gt;     &amp;lt;/b&amp;gt;&lt;br /&gt;
      ${exampleVar} &amp;lt;-- Error&lt;br /&gt;     &lt;br /&gt; &amp;lt;/p&amp;gt;&lt;/p&gt;
&lt;p&gt;Would we have to make any modifications to FreeMarkerPortlet?&lt;/p&gt;</summary>
    <dc:creator>Adrián Pol</dc:creator>
    <dc:date>2023-03-31T09:04:08Z</dc:date>
  </entry>
  <entry>
    <title>RE: Use attributes without renderRequest in a FreemarkerPortlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121683437" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121683437</id>
    <updated>2023-03-30T15:30:19Z</updated>
    <published>2023-03-30T15:30:18Z</published>
    <summary type="html">&lt;p&gt;Wow, I didn't think anyone was doing FM portlets anymore...&lt;/p&gt;
&lt;p&gt;Liferay uses FM for themes and template handling (for web structures,
  ADTs, etc) and it uses TemplateContextContributors, but these are
  really just wrappers that are used when initializing the FM context
  object to inject values and services into the context so they are
  available to FM.&lt;/p&gt;
&lt;p&gt;I don't know how you're getting FM to handle the rendering of your
  panel, but at some point you're going to be creating the context
  object to pass to FM to use to render the template (just like the
  renderRequest is being injected), so you just have to find out how
  that context is being created and then the way to inject your values
  and services into the context.&lt;/p&gt;
&lt;p&gt;I could help you with this, but most of the details about how you're
  building your portlet weren't provided, so this is the best I can do
  at the moment.&lt;/p&gt;</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2023-03-30T15:30:18Z</dc:date>
  </entry>
  <entry>
    <title>Use attributes without renderRequest in a FreemarkerPortlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121678663" />
    <author>
      <name>Adrián Pol</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121678663</id>
    <updated>2023-03-23T18:15:54Z</updated>
    <published>2023-03-23T15:51:26Z</published>
    <summary type="html">&lt;p&gt;Hello! I am testing a portlet with the views in Freemarker and for
  now everything is going great, doing some research on the forum I have
  seen that in order to pass objects to the view we have to use
  renderRest.setAttribute(&amp;quot;test&amp;quot;, test) (to send it) and
  renderRequest.getAttribute(&amp;quot;test&amp;quot;) (to handle it in the ftl).&lt;/p&gt;
&lt;p&gt;is there a way to avoid using the renderRequest.getAttribute and
  directly put the object(${test}) as in the Templates or as in a
  Liferay portlet of Spring type?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;
  &lt;img alt="" src="/documents/d/guest/captura-4-png?imagePreview=1" /&gt;
  &lt;br /&gt;  &lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;</summary>
    <dc:creator>Adrián Pol</dc:creator>
    <dc:date>2023-03-23T15:51:26Z</dc:date>
  </entry>
</feed>
