Liferay Portlet Struts动作路径钩错误

时间:2015-08-31 11:18:41

标签: liferay liferay-6

我试图覆盖" / blogs / view_entry"支柱路径。以下是liferay-hook.xml中的条目

<struts-action>
        <struts-action-path>/blogs/view_entry</struts-action-path>
        <struts-action-impl>com.smb.hook.action.BlogCustomEditAction</struts-action-impl>
</struts-action>

每当我点击Blogs portlet中的任何博客条目时,它都会重定向到

  

http://localhost:8080/web/guest/home/-/blogs/test-blog-for-testing?_33_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D33%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_count%3D2

并且博客portlet变得不可见。

在控制台,我可以看到在render方法中添加了测试打印语句。之后记录以下错误消息:

ERROR [RuntimePageImpl-22][PortletRequestProcessor:466] Forward does not exist

以下是覆盖的方法:

@Override
    public void processAction(StrutsPortletAction originalStrutsPortletAction,
            PortletConfig portletConfig, ActionRequest actionRequest,
            ActionResponse actionResponse) throws Exception {
        System.out.println("processAction :");
        super.processAction(originalStrutsPortletAction, portletConfig, actionRequest,
                actionResponse);
    }

    @Override
    public String render(StrutsPortletAction originalStrutsPortletAction,
            PortletConfig portletConfig, RenderRequest renderRequest,
            RenderResponse renderResponse) throws Exception {
        System.out.println("render :");
        return super.render(originalStrutsPortletAction, portletConfig, renderRequest,
                renderResponse);
    }

    @Override
    public void serveResource(StrutsPortletAction originalStrutsPortletAction,
            PortletConfig portletConfig, ResourceRequest resourceRequest,
            ResourceResponse resourceResponse) throws Exception {
        System.out.println("serveResource :");
        super.serveResource(originalStrutsPortletAction, portletConfig,
                resourceRequest, resourceResponse);
    }

我已尝试为originalStrutsPortletAction传递null,如liferay dev site中的一个示例所示,但输出没有变化。

对此有任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:3)

我猜你扩展BaseStrutsPortletAction(未在你的代码段中说明)。

BaseStrutsPortletAction的默认方法委托给originalStrutsPortletAction - 但他们委托你的班级的方法没有originalStrutsPortletAction,这些方法是空的默认值。

所以你必须自己打电话给originalStrutsPortletAction

@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction,
        PortletConfig portletConfig, ActionRequest actionRequest,
        ActionResponse actionResponse) throws Exception {
    originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);
}

@Override
public String render(StrutsPortletAction originalStrutsPortletAction,
        PortletConfig portletConfig, RenderRequest renderRequest,
        RenderResponse renderResponse) throws Exception {
    return originalStrutsPortletAction.render(portletConfig, renderRequest, renderResponse);
}

@Override
public void serveResource(StrutsPortletAction originalStrutsPortletAction,
        PortletConfig portletConfig, ResourceRequest resourceRequest,
        ResourceResponse resourceResponse) throws Exception {
    originalStrutsPortletAction.serveResource(portletConfig, resourceRequest, resourceResponse);
}