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.

Thursday, April 30, 2015

Implementing Application Display Template in Custom Portlet


In the following post we will see how to implement Application Display Template to a custom portlet. We are assuming that we have a custom portlet as created in previous post.

Following are steps that we need to follow -


1. Create StudentPortletDisplayTemplateHandler.java class. This class extends BasePortletDisplayTemplateHandler class provided by Liferay.


2. Declare StudentPortletDisplayTemplateHandler class in liferay-portlet.xml file.


3. Configure permissions to allow users to manage application display templates.


4. Use tag to show ADT options in configuration jsp.



5. Update the view jsp to render the data using selected ADT.



6. Create the template and test. Following Freemarker sample code snippet is from liferay documentation page.



Please share your feedback if any ....