创建Liferay portlet配置页面

时间:2013-11-08 07:35:56

标签: java spring-mvc liferay portlet

我正在尝试为Liferay portlet创建配置页面,因此我可以为它设置一些参数。例如,我想选择控制器在查看时应显示的页面。配置应位于此处:

enter image description here

所以我为这个配置创建了一个控制器:

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";
    }
}

视图部分的JSP页面:

<%@ page pageEncoding="UTF-8"%>
<%@ include file="../init.jsp"%>

<form>
    Select:
    <select>
        <option>1</option>
        <option>2</option>
        <option>3</option>
    </select>
</form>

我已将我的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>

和我的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>

但我无法看到配置标签。我还需要配置什么才能查看配置吗?

1 个答案:

答案 0 :(得分:3)

而不是return "/sandboxPortlet/config";提供return "/html/sandboxPortlet/config.jsp";

您必须提供完整的jsp路径。