Thursday, June 18, 2015

Refresh Portlet After Saving Custom Portlet Configurations

In Liferay custom portlet, when we save our custom configuration page, changes are not reflected without refreshing the portlet and we have to do it manually. Instead of this we can use following script in processAction method of Configuration class -


LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig;
String portletResource = ParamUtil.getString(actionRequest, "portletResource");
SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource);
SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION);


Hope it will be helpful.