Search code examples
liferayportlet

Different kind of redirection in a portlet


I would like to know the different kind of redirections in the portets and how to realize them. How to go from one view (jsp file) to another in the same portlet, how to go from one page to another from a portlet. It is for the purpose of making a form so I would like to do this in a processAction.


Solution

  • Your answer is not clear. However, in Liferay, you can route your application using urls. For example, you can create a portlet action url on your own. You can try something like this:

    HttpServletRequest request = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(actionRequest));
    PortletURL oPortletURL = PortletURLFactoryUtil.create(request, <portletName> , <plid>, <portletPhase>);
    oPortletURL.setParameter("myParameter1", "parameter1");
    String portletURL = oPortletURL.toString();
    

    Where:

    <portletName> is the javax.portlet.name of your portlet

    <plid> is the ID of a page where is located an instance of your <portletName> portlet (try to check Layout and LayoutFriendlyUrl tables)

    <portletPhase> is the phase you need, for example PortletRequest.ACTION_PHASE

    Finally, you can use setParameter() method to pass parameters in query string.