<?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>Which classes are available for staticUtil in Freemarker Templates?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111698310" />
  <subtitle>Which classes are available for staticUtil in Freemarker Templates?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111698310</id>
  <updated>2026-04-06T21:52:40Z</updated>
  <dc:date>2026-04-06T21:52:40Z</dc:date>
  <entry>
    <title>RE: Which classes are available for staticUtil in Freemarker Templates?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118466267" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118466267</id>
    <updated>2020-02-10T07:46:55Z</updated>
    <published>2020-02-10T07:46:55Z</published>
    <summary type="html">Hmm.&lt;br /&gt;AFAIKT it is the classloader of the current thread. See getBeansWrapper method in FreeMarkerManager.&lt;br /&gt;&lt;a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-template/portal-template-freemarker/src/main/java/com/liferay/portal/template/freemarker/internal/FreeMarkerManager.java"&gt;https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-template/portal-template-freemarker/src/main/java/com/liferay/portal/template/freemarker/internal/FreeMarkerManager.java&lt;/a&gt;&lt;br /&gt;I am not sure what that means though, practically speaking. I guess, the classloader of the current portlet is used. Of course, something could manipulate the thread classloader before calling that method and switch it elsewhere.</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2020-02-10T07:46:55Z</dc:date>
  </entry>
  <entry>
    <title>RE: Which classes are available for staticUtil in Freemarker Templates?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118445963" />
    <author>
      <name>Dominik Marks</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118445963</id>
    <updated>2020-02-06T15:30:32Z</updated>
    <published>2020-02-06T15:30:32Z</published>
    <summary type="html">Sorry Sebastien, no I did not find an answer to my initial question yet.</summary>
    <dc:creator>Dominik Marks</dc:creator>
    <dc:date>2020-02-06T15:30:32Z</dc:date>
  </entry>
  <entry>
    <title>RE: Which classes are available for staticUtil in Freemarker Templates?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118389211" />
    <author>
      <name>SEBASTIEN PAYEN</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118389211</id>
    <updated>2020-01-31T10:01:49Z</updated>
    <published>2020-01-31T10:01:49Z</published>
    <summary type="html">Hello Dominik,I have the same problem.Did you find an aswer to your initial question?&lt;br /&gt;Thanks.</summary>
    <dc:creator>SEBASTIEN PAYEN</dc:creator>
    <dc:date>2020-01-31T10:01:49Z</dc:date>
  </entry>
  <entry>
    <title>RE: Which classes are available for staticUtil in Freemarker Templates?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111717997" />
    <author>
      <name>Dominik Marks</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111717997</id>
    <updated>2018-12-03T12:09:12Z</updated>
    <published>2018-12-03T12:09:12Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;Thanks Rayapp for your answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However I specifically asked about the possibilities for
    &lt;code&gt;staticUtil &lt;/code&gt;and which classes are avaible for this. Do
  you know which classes are available here?&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Dominik Marks</dc:creator>
    <dc:date>2018-12-03T12:09:12Z</dc:date>
  </entry>
  <entry>
    <title>RE: Which classes are available for staticUtil in Freemarker Templates?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111704015" />
    <author>
      <name>Rayappa Hattarwat</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111704015</id>
    <updated>2018-11-30T06:47:37Z</updated>
    <published>2018-11-30T06:47:37Z</published>
    <summary type="html">&lt;p&gt;Hi Dominik,&lt;/p&gt;
&lt;p&gt;You can access web content template in free marker bellow code&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&amp;lt;#assign article = renderer.getArticle() /&amp;gt;&lt;br /&gt; &amp;lt;#assign
  className = renderer.getClassName() /&amp;gt;&lt;br /&gt; &amp;lt;#if className == &amp;quot;com.liferay.journal.model.JournalArticle&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;!---&lt;/p&gt;
&lt;p&gt; enter your logic here&lt;/p&gt;
&lt;p&gt;--&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/#if&amp;gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Rayappa&lt;/p&gt;</summary>
    <dc:creator>Rayappa Hattarwat</dc:creator>
    <dc:date>2018-11-30T06:47:37Z</dc:date>
  </entry>
  <entry>
    <title>Which classes are available for staticUtil in Freemarker Templates?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111698309" />
    <author>
      <name>Dominik Marks</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111698309</id>
    <updated>2018-11-29T13:25:09Z</updated>
    <published>2018-11-29T13:25:09Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;In our project we use &lt;code&gt;staticUtil&lt;/code&gt; to access static
  classes and call methods inside Freemarker Templates (e.g. Web Content
  Templates)&amp;nbsp;like this&lt;/p&gt;
&lt;pre&gt;
&amp;lt;#assign 
    textFormatter = staticUtil["com.liferay.portal.kernel.util.TextFormatter"]
    sizeFormatted = textFormatter.formatStorageSize(file.size, locale) 
/&amp;gt;
&lt;/pre&gt;
&lt;p&gt;However it seems that not all classes are available for
  &lt;code&gt;staticUtil&lt;/code&gt;. For example I tried to access
  &lt;code&gt;javax.imageio.ImageIO&lt;/code&gt; and got a &lt;code&gt;ClassNotFoundException&lt;/code&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there any list which classes are available here? Internally it
  seems that &lt;code&gt;Class.forName() &lt;/code&gt;is called. So which
  Classloader is used here??&lt;/p&gt;
&lt;p&gt;From some tests I found that the following classes are available:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;java.util.Calendar&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;java.util.regex.Pattern&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;com.liferay.portal.kernel.service.ServiceContextThreadLocal&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;com.liferay.portal.kernel.util.TextFormatter&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The following classes throw a &lt;code&gt;ClassNotFoundException&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;javax.image.ImageIO&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;com.liferay.portal.kernel.image.ImageToolUtil&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Thank's for your help.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Dominik Marks</dc:creator>
    <dc:date>2018-11-29T13:25:09Z</dc:date>
  </entry>
</feed>
