Portlet configuration page use some parameters for liferay portlet. For example I would like to select what page should a controller display when viewing it.
Below steps help you to create configuration page in liferay :
Step 1: Create controller for config
import com.liferay.portal.kernel.portlet.ConfigurationAction;
import javax.portlet.*;
public class SandboxPortletConfig implements ConfigurationAction {
@Override
public void processAction(PortletConfig portletConfig,
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
}
@Override
public String render(PortletConfig portletConfig, RenderRequest renderRequest,
RenderResponse renderResponse) throws Exception {
return "html/sandboxPortlet/config.jsp";
}
}
Step 2: JSP page for the view part:
<%@ page pageEncoding="UTF-8"%>
<%@ include file="../init.jsp"%>
<form>
Select:
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</form>
Step 3: set up portlet.xml to include:
<portlet>
<portlet-name>sandboxPortlet</portlet-name>
<display-name>Sandbox Portlet</display-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/spring/sandbox-portlet-context.xml</value>
</init-param>
<init-param>
<name>config-jsp</name>
<value>/WEB-INF/html/sandboxPortlet/config.jsp</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
</supports>
<portlet-info>
<title>Sandbox Portlet</title>
<short-title>Sandbox</short-title>
<keywords>sandbox test testing</keywords>
</portlet-info>
</portlet>
Step4: liferay-portlet.xml to be like:
<portlet>
<portlet-name>sandboxPortlet</portlet-name>
<instanceable>false</instanceable>
<configuration-action-class>path.to.the.portlet.sandboxPortlet.SandboxPortletConfig</configuration-action-class>
</portlet>
0 Comment(s)