Problems with configuration action in a osgi moduleProblems with configuration action in a osgi modulehttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1194766442024-03-28T14:37:53Z2024-03-28T14:37:53ZRE: Problems with configuration action in a osgi modulealikol kalikohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1195407432020-07-05T16:55:21Z2020-07-05T16:55:21ZThe OSGi Alliance has developed a specification describing integration between OSGi and CDI.<br /><a href="https://kodi.software/">Kodi</a> <a href="https://kodi.software/">nox</a>alikol kaliko2020-07-05T16:55:21ZProblems with configuration action in a osgi moduleElsa Kenthttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1194766432020-06-24T14:51:29Z2020-06-24T14:51:29Z<html><head></head><body>Hi all<br>I've followed the following articles to implement a simple portlet with a configuration action to store custom preferencies I have implemented in a configuration.jsp:<br><br><a href="https://help.liferay.com/hc/es/articles/360018161391-Making-Your-Applications-Configurable">https://help.liferay.com/hc/es/articles/360018161391-Making-Your-Applications-Configurable</a><br><a href="https://help.liferay.com/hc/es/articles/360017882392-Implementing-Configuration-Actions">https://help.liferay.com/hc/es/articles/360017882392-Implementing-Configuration-Actions</a><br>Also I've checked and compared the following liferay sample: <br><a href="https://github.com/liferay/liferay-blade-samples/tree/7.2/gradle/apps/configuration-action/src/main/java/com/liferay/blade/samples/configurationaction">https://github.com/liferay/liferay-blade-samples/tree/7.2/gradle/apps/configuration-action/src/main/java/com/liferay/blade/samples/configurationaction</a><br><strong></strong><br><strong>I'm using liferay 7.2 GA2 CE.</strong> The problem is that for any unknown reason, the preference's values stored in the processAction are not being updated in the _configuration object that both Portlet and ConfigurationAction classes have in the "volatile" variable. I've debugged liferay code to check the preferences update process (processAction) and everything seems fine. <br><br>Also I've checked the preferences table and the xml of the preferences has correct values everytime I change them. But when both Portlet and ConfigurationAction classes are getting the values in the configuration object, they are not updated, they always have the default values of the configuration object (therefore, the log.debug messages _configuration.getScope() and _configuration.isSiteScope() are displaying the default values) .<br>Is there any missing step to configure the "volatile" _configuration objects of Portlet and ConfigurationAction classes to be "refreshed" everytime the preferences are updated in the ConfigurationAction?<br><br>This is the configuration class method:<br><blockquote><br><pre><code>
@Meta.OCD(id="com.test.configuration.MyConfiguration")
public interface MyConfiguration {
&nbsp;&nbsp;&nbsp; @Meta.AD(deflt = "true",required=false)
&nbsp;&nbsp;&nbsp; public boolean isSiteScope();
&nbsp;&nbsp;&nbsp; @Meta.AD(required=false)
&nbsp;&nbsp;&nbsp; public long siteScope();
</code></pre><br></blockquote><br><br>This is the configuration action class:<br><blockquote><br><pre><code>
configurationPid = "com.test.configuration.MyConfiguration",
...
public class MyConfigurationAction extends DefaultConfigurationAction {
...
@Override
&nbsp;&nbsp;&nbsp; public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.debug("START PROCESS ACTION CONFIGURATION");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String isSiteScope = ParamUtil.getString(actionRequest, "isSiteScope");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String siteScope = ParamUtil.getString(actionRequest, "siteScope");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.debug("isSiteScope:" + isSiteScope);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.debug("siteScope:" + siteScope);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setPreference(actionRequest,"isSiteScope",isSiteScope);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setPreference(actionRequest,"siteScope",siteScope);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super.processAction(portletConfig, actionRequest, actionResponse);
&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; @Activate
&nbsp;&nbsp;&nbsp; @Modified
&nbsp;&nbsp;&nbsp; protected void activate (Map<string,object> properties){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _configuration = ConfigurableUtil.createConfigurable(MyConfiguration.class,properties);
&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; private volatile MyConfiguration _configuration;
</string,object></code></pre><br></blockquote><br><br>This is the Portlet class doView and code related to configuration object:<br><blockquote><br><pre><code>
configurationPid = "com.test.configuration.MyConfiguration",
...
@Override
&nbsp;&nbsp; &nbsp;public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_log.debug("START VIEW");
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; //Send configuration of the portlet to the request
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;renderRequest.setAttribute(
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;MyConfiguration.class.getName(),
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_configuration);
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_log.debug("configuration: isSiteScope=" + _configuration.isSiteScope());
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_log.debug("configuration: siteScope=" + _configuration.siteScope());
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_log.debug("END VIEW");
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;super.doView(renderRequest, renderResponse);
&nbsp;&nbsp; &nbsp;}
&nbsp;&nbsp; &nbsp;@Activate
&nbsp;&nbsp; &nbsp;@Modified
&nbsp;&nbsp; &nbsp;protected void activate (Map<string,object> properties){
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; _configuration = ConfigurableUtil.createConfigurable(MyConfiguration.class,properties);
&nbsp;&nbsp; &nbsp;}
&nbsp;&nbsp;
&nbsp;&nbsp; &nbsp;private volatile MyConfiguration _configuration;
</string,object></code></pre><br></blockquot