Creating custom mode in liferay portlet
To create Configuration mode in liferay first of all you need to make entry in liferay-portlet.xml
<configuration-action-class>com.custom.portlets.action.ConfigurationActionImpl</configuration-action-class>
ConfigurationActionImpl extends BaseConfigurationAction which is available in portal-kernal.jar
Basically you need to implement two methods inside this class
1) Render()
2) ProcessAction()
Render method takes PortletConfig, RenderRequest, RenderResponse and returns the configuration page (Page to display in custom mode)
Create Action URL
<liferay-portlet:actionurl portletconfiguration="true" var="addURL"> <portlet:param name="resourcePrimKey" value="<%=Id %>"></portlet:param> </liferay-portlet:actionurl>
To create Configuration mode in liferay first of all you need to make entry in liferay-portlet.xml
<configuration-action-class>com.custom.portlets.action.ConfigurationActionImpl</configuration-action-class>
ConfigurationActionImpl extends BaseConfigurationAction which is available in portal-kernal.jar
Basically you need to implement two methods inside this class
1) Render()
2) ProcessAction()
Render method takes PortletConfig, RenderRequest, RenderResponse and returns the configuration page (Page to display in custom mode)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConfigurationActionImpl extends BaseConfigurationAction { | |
public void processAction( | |
PortletConfig portletConfig, ActionRequest actionRequest, | |
ActionResponse actionResponse) | |
throws Exception { | |
//Logic for action | |
} | |
public String render( | |
PortletConfig portletConfig, RenderRequest renderRequest, | |
RenderResponse renderResponse) | |
throws Exception { | |
List<product> productList = Collections.EMPTY_LIST; | |
try { | |
productList = ProductLocalServiceUtil.getProducts(0, ProductLocalServiceUtil.getProductCount()); | |
} catch (SystemException e) { | |
_log.debug(e); | |
} | |
renderRequest.setAttribute("productList", productList); | |
return "/pageForCustomMode.jsp"; | |
} | |
} |
Create Action URL
<liferay-portlet:actionurl portletconfiguration="true" var="addURL"> <portlet:param name="resourcePrimKey" value="<%=Id %>"></portlet:param> </liferay-portlet:actionurl>