Liferay 7.1: export values from a Spring portlet for use in a themeLiferay 7.1: export values from a Spring portlet for use in a themehttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1178112502024-03-29T09:00:51Z2024-03-29T09:00:51ZRE: Liferay 7.1: export values from a Spring portlet for use in a themePhilippe Tranhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1178116212019-11-17T18:05:45Z2019-11-17T18:05:45Z<html><head></head><body>I found the solution...<br><br>1. Create a class extending com.liferay.portal.kernel.events.Action,<br>2. In the <strong>run</strong> method, build a Map of ("variableName", variableValue), then publish it to FreeMarker using:<br><pre><code>request.setAttribute(WebKeys.FTL_VARIABLES, contextObjects);</code></pre><br>3. In the resources/<strong>portal.properties</strong> file, add <strong>servlet.service.events.pre=[yourActionClass]</strong><br>4. In the WEB-INF/<strong>liferay-hook.xml</strong> file, add <strong><hook><portal-properties>portal.properties</portal-properties></hook></strong><br>Hope this will help.</body></html>Philippe Tran2019-11-17T18:05:45ZLiferay 7.1: export values from a Spring portlet for use in a themePhilippe Tranhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1178112492019-11-17T15:54:06Z2019-11-17T15:54:06Z<html><head></head><body>Hello all,I would like to make some values from a Spring (war) portlet available to a theme. I tried implementing a <strong>LifecycleAction<span style="color: #212529"></span><span style="font-size: 14px;"> </span></strong>with<pre><code>@Component(immediate = true,&nbsp;property = {"key=servlet.service.events.pre"},&nbsp;service = LifecycleAction.class)</code></pre>But the <strong>processLifecycleEvent(LifecycleEvent)</strong> method is never called.<br><br>I implemented also a <strong>TemplateContextContributor</strong><span style="font-size: 16px;">, with</span><pre><code>@Component(immediate = true,&nbsp;property = {"type=" + TemplateContextContributor.TYPE_THEME},&nbsp;service = TemplateContextContributor.class)</code></pre>But the <span style="font-size: 16px;"><strong>prepare(Map<String, Object> contextObjects, HttpServletRequest)</strong> </span>method is also never called.<br><br>My questions are:<br>- which component should I implement, to get called from a WAR portlet with the "<strong>servlet.service.events.pre</strong>" event ?<br>- how to publish a value in this context (ex: event.getRequest().setAttribute(WebKeys.VM_VARIABLES, myVariableMap) <span style="font-size: 16px;">)</span><br><br><span style="font-size: 16px;">Note that I added WEB-INF/liferay-hook.xml and WEB-INF/src/portal.properties files, as explained in </span><a href="https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/overriding-portal-properties-using-a-hook">https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/overriding-portal-properties-using-a-hook</a><span style="font-size: 16px;">. I even tried with resources/portal-ext.properties and resources/portal.properties configuration files,