Wednesday, April 27, 2016

Generic Templates Liferay 6.2


Before Liferay 6.2, each template had to be associated with a structure. Now, we can create a generic template and reuse its code for any structure. Generic templates can be embedded in other templates, which allows for reusable code,

Suppose you have three different web content articles and structures with similar requirements. Instead of creating three different templates from scratch, you can use the same generic template for all three and build off of it. This creates a smarter and more efficient process when creating a multitude of similar web content articles. Generic templates are created the same way as regular, structure-based templates. The only setting that differs is the Structure option, which you’ll need to leave blank to create a generic template.

Embedding Generic Template in other template:

In FreeMarker:
<#include "${templatesPath}/<generic-template-key>" />


In Velocity:

#parse ("$templatesPath/<generic-template-key>")

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 ....

Thursday, March 20, 2014

Not getting parameters in controller class in Liferay 6.2 (Namespaced Parameters)


Starting from Liferay 6.2 only allows namespaced parameters. If we want to send unnamespaced parameters we need to turn the filter off. To achieve the same we need to add the following property in portlet's liferay-portlet.xml file.


<requires-namespaced-parameters>false</requires-namespaced-parameters>

Thursday, December 26, 2013

Friday, November 29, 2013

Kaleo Workflow Configuration for Custom Portlet in Liferay 6.1

1. Make sure you have deployed kaleo workflow war in your liferay portal.

2. Create the service.xml


3. Build the service

4. Edit the FeedbackLocalServiceImpl class and add the following methods:



5. Make the following entries in liferay-portlet.xml file



6. create the FeedbackAssetRendererFactory class



7. create the FeedbackAssetRenderer class-



8. create the /html/feedback.jsp file.


9. create the FeedbackWorkflowHandler class -



10. We are done with all the changes now, to see our portlet in action go to control panel → Workflow Configuration and set the workflow for your custom portlet.