0

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

这是我的代码:

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

1 回答 1

0

试试下面的代码,

钩子.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 创建了上面的钩子希望它对你有帮助!

于 2013-06-20T07:31:03.870 回答