Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Liferay 自定义操作类中的sendRedirect_Liferay_Struts_Liferay 6_Liferay Hook - Fatal编程技术网

Liferay 自定义操作类中的sendRedirect

Liferay 自定义操作类中的sendRedirect,liferay,struts,liferay-6,liferay-hook,Liferay,Struts,Liferay 6,Liferay Hook,我正在覆盖日历portlet的一个操作。我想做一些功能,然后重定向到另一个JSP。我尝试按如下方式使用sendRedirect函数: 1. 二, actionResponse.sendRedirect(“/calendar/view”) 三, 但是,这些方法都不会导致jsp重定向到另一个方法。 我在processAction函数中这样做,并扩展BaseStrutsPortletAction 有什么建议可以解决吗 这是我的覆盖文件: public class TestAction extends

我正在覆盖日历portlet的一个操作。我想做一些功能,然后重定向到另一个JSP。我尝试按如下方式使用sendRedirect函数:
1.

二,

actionResponse.sendRedirect(“/calendar/view”)

三,

但是,这些方法都不会导致jsp重定向到另一个方法。 我在processAction函数中这样做,并扩展BaseStrutsPortletAction

有什么建议可以解决吗

这是我的覆盖文件:

public class TestAction extends BaseStrutsPortletAction {
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
      ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    String cmdConstants = ParamUtil.getString(actionRequest, Constants.CMD);
    if (cmdConstants.equals(Constants.APPROVE)) {
        //some function
        actionResponse.setRenderParameter("test", "test");
        originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);
    }
  }

  public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, RenderRequest renderRequest,
      RenderResponse renderResponse) throws Exception {
    String cmdConstants = ParamUtil.getString(renderRequest, Constants.CMD);
    if (cmdConstants.equals(Constants.APPROVE)) {
      if (renderRequest.getParameter("test").equals("test")) {
        return "/portlet/calendar/view.jsp";
      }
    }
    return originalStrutsPortletAction.render(null, portletConfig, renderRequest, renderResponse);
  }
}

我建议也重写渲染方法。在processAction和render方法中根据属性返回将被呈现的jspPath设置请求属性。有什么建议吗?在ProcessAction中,我写了以下内容:actionResponse.setRenderParameter(“test”,“test”);在render中,我写了以下内容:if(renderRequest.getParameter(“test”).equals(“test”){return”/portlet/calendar/view.jsp”}你能把覆盖的文件发布到这里吗???@Danish我把我的文件添加到上面的帖子中了。
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletURL url = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest), "8", themeDisplay.getPlid(),
PortletRequest.RENDER_PHASE);
url.setParameter("struts_action", "/calendar/view");
actionResponse.sendRedirect (url.toString()) ;
public class TestAction extends BaseStrutsPortletAction {
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
      ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    String cmdConstants = ParamUtil.getString(actionRequest, Constants.CMD);
    if (cmdConstants.equals(Constants.APPROVE)) {
        //some function
        actionResponse.setRenderParameter("test", "test");
        originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);
    }
  }

  public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, RenderRequest renderRequest,
      RenderResponse renderResponse) throws Exception {
    String cmdConstants = ParamUtil.getString(renderRequest, Constants.CMD);
    if (cmdConstants.equals(Constants.APPROVE)) {
      if (renderRequest.getParameter("test").equals("test")) {
        return "/portlet/calendar/view.jsp";
      }
    }
    return originalStrutsPortletAction.render(null, portletConfig, renderRequest, renderResponse);
  }
}