Liferay Hook调用扩展方法

时间:2013-06-19 16:47:12

标签: liferay

我在liferay钩子中有新动作,理想情况下是调用在扩展中创建的方法。但是在执行操作的运行时,它会抛出异常 抛出java.lang.ClassNotFoundException  对于在扩展中创建的方法。 是否有人在liferay钩子中创建了类似的动作?如果是的话,遇到这个问题的解决方案是什么?

这是我的代码:

public class ExampleStrutsAction extends BaseStrutsAction { 
    public String execute( HttpServletRequest request, HttpServletResponse response) throws Exception {
        String name = ParamUtil.get(request, "name", "World");
        ThemeDisplay themeDisplay= (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
        BSCDynamicDataListLocalServiceUtil.cloneDynamicDataListPageInSuborganization(the‌​meDisplay, name);
        return "/portal/sample.jsp"; 
    }
} 

1 个答案:

答案 0 :(得分:0)

尝试以下代码,

hook.xml

<hook>
    <portal-properties>portal.properties</portal-properties>
    <language-properties>
        content/Language.properties
    </language-properties>
    <custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
    <struts-action>
        <struts-action-path>/my_account/edit_user</struts-action-path>
        <struts-action-impl>com.test.hook.action.EditUserAction</struts-action-impl>
    </struts-action>
    <struts-action>
        <struts-action-path>/users_admin/edit_user</struts-action-path>
        <struts-action-impl>com.test.hook.action.EditUserAction</struts-action-impl>
    </struts-action>

</hook>

EditUserAction类

public class EditUserAction extends BaseStrutsPortletAction
{
    @Override
    public void processAction(final StrutsPortletAction originalStrutsPortletAction, final PortletConfig portletConfig,
            final ActionRequest actionRequest, final ActionResponse actionResponse) throws Exception
    {
        // add your custom code
        originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);
    }

    @Override
    public String render(final StrutsPortletAction originalStrutsPortletAction, final PortletConfig portletConfig, final RenderRequest renderRequest,
            final RenderResponse renderResponse) throws Exception
    {
        //add your custom code
        return originalStrutsPortletAction.render(portletConfig, renderRequest, renderResponse);
    }

}

我在控制面板中为EditUserAction创建了上面的钩子 希望它可以帮助你!!