【问题标题】:Add a conf menu to my portlet将 conf 菜单添加到我的 portlet
【发布时间】:2012-06-18 07:05:42
【问题描述】:

我正在尝试在我的自定义 portlet 的 conf 中添加一个选项卡,在本地导入/导出和权限旁边。

喜欢这张图片:http://imageshack.us/photo/my-images/716/sampledn.png/

此选项卡必须允许更改定义某些变量的 conf.properties 中的参数值。

我该怎么做?

问候。

【问题讨论】:

    标签: liferay portlet


    【解决方案1】:

    是的,您可以首先将其添加到您的 portlet.xml 作为“portlet”节点的子节点:

        <init-param>
            <name>config-jsp</name>
            <value>/html/config.jsp</value>
        </init-param>
    

    您需要在 liferay-portlet.xml 中将其添加为“portlet”节点的子节点:

    <configuration-action-class>com.yourportlet.action.ConfigurationActionImpl</configuration-action-class>
    

    然后您需要在您在 XML 中指定的目录中创建这些文件,并且您的 ConfigurationActionImpl 应该实现 ConfigurationAction 接口,因此框架如下所示:

    public class ConfigurationActionImpl implements ConfigurationAction {
    
    @Override
    public String render(PortletConfig config, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {                   
        return "/html/config.jsp";
    }
    

    如果这有帮助或者您还有其他问题,请告诉我! :)

    【讨论】:

    • 这有点帮助,但我还有其他问题:如果我在我的 portlet 类中实现 ConfigurationAction,而不是创建一个新类,是 com.yourportlet.action。 ConfigurationActionImpl 变成 com.yourportlet.action.myportletclass ? ps:因为我的名声(少于 15 人),我不能投票,但是谢谢
    • 您不希望您的portlet 实现ConfigurationAction(实际上我不知道这是否可行),因为您希望将此逻辑与您的Portlet 代码分开(如果这有意义的话)。最好为 Configuration 和 Portlet 创建单独的类。
    • 如果可行,请接受答案,不要担心投票! :) 如果您还有任何问题,请提出!
    • 当我在 liferay-portlet.xml 中添加该行时,出现以下错误:“此 portlet 已取消部署。请重新部署它或将其从页面中删除。”我检查了名字,没有错误。这怎么可能?
    • 这通常发生在 Portlet 尝试重新部署但出现错误时,因此它已从服务器中删除并且没有再次完全部署。部署时您的日志中是否有任何错误?您是否尝试过重新部署您的 portlet?
    【解决方案2】:

    将编辑模式添加到您的 portlet.xml:

        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>view</portlet-mode>
            <portlet-mode>edit</portlet-mode> <!-- add this line -->
        </supports>
    

    然后您将在菜单中看到首选项选项。覆盖 portlet 类中的 doEdit 方法以呈现编辑模式的内容。

    编辑:

    更高级的解决方案:

    您可以通过钩子更改门户jsp来添加另一个选项卡。你需要改变的jsp是:

    /html/portlet/portlet_configuration/tabs1.jsp

    请注意,这将更改所有 portlet 的配置窗口。

    【讨论】:

    • 我真的用首选项菜单做到这一点吗?我想我可以在我链接的图片中做出喜欢(用它编辑我的问题)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    相关资源
    最近更新 更多