[英]Creating a Liferay portlet configuration page
I'm trying to create a configuration page for a Liferay portlet, so I can set some parameters for it. 我正在尝试为Liferay portlet创建配置页面,因此我可以为它设置一些参数。 For example I would like to choose what page should a controller display when viewing it.
例如,我想选择控制器在查看时应显示的页面。 The configuration should be located here:
配置应位于此处:
So I've created a controller for the config like this: 所以我为配置创建了一个控制器,如下所示:
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 "/sandboxPortlet/config";
}
}
A JSP page for the view part: 视图部分的JSP页面:
<%@ page pageEncoding="UTF-8"%>
<%@ include file="../init.jsp"%>
<form>
Select:
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</form>
I've set up my portlet.xml to include: 我已经设置了我的portlet.xml来包含:
<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>
and my liferay-portlet.xml to be like: 和我的liferay-portlet.xml一样:
<portlet>
<portlet-name>sandboxPortlet</portlet-name>
<instanceable>false</instanceable>
<configuration-action-class>path.to.the.portlet.sandboxPortlet.SandboxPortletConfig</configuration-action-class>
</portlet>
But I'm unable to see the configuration tab. 但我无法看到配置选项卡。 Is there anything else that I need to configure in order to see the configuration, please?
有什么我需要配置才能看到配置吗?
Instead of return "/sandboxPortlet/config";
而不是
return "/sandboxPortlet/config";
provide return "/html/sandboxPortlet/config.jsp";
提供
return "/html/sandboxPortlet/config.jsp";
You have to provide full jsp path. 您必须提供完整的jsp路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.