Posts tagged ‘windowstate’

Create a URL based on PortletId in Liferay

Necessary package need to Import in JSP page
    <%@ page import="com.liferay.portlet.PortletURLFactoryUtil"%>
    <%@ page import="com.liferay.portal.kernel.portlet.LiferayPortletURL"%>
    <%@ page import="javax.portlet.PortletRequest"%>
    <%@ page import="javax.portlet.PortletURL"%>
    <%@ page import="javax.servlet.http.HttpServletRequest"%>

Syntax:

portletURL URL = PortletURLFactoryUtil.create(request, portletId, plid, lifecycle);

OR

LiferayPortletURL URL = PortletURLFactoryUtil.create(request, portletId, plid, lifecycle);

For creating PortletRequest URL


ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
LiferayPortletURL renderURL = PortletURLFactoryUtil.create(request, portletId, plid, PortletRequest.RENDER_PHASE);
renderURL.setWindowState(WindowState.NORMAL); //to set windowsState
renderURL.setPortletMode(PortletMode.VIEW);  //to set portletmode
renderURL.setParameter(arg0,arg1);  /to set the parameter ex:ipcActionURL.setParameter("struts_action",/etc/reports/add);

LiferayPortletURL actionURL = PortletURLFactoryUtil.create(request, "portletId", plid, PortletRequest.ACTION_PHASE);
actionURL.setWindowState(WindowState.NORMAL); //to set windowsState
actionURL.setPortletMode(PortletMode.VIEW);  //to set portletmode
actionURL.setParameter(arg0,arg1);  /to set the parameter ex:ipcActionURL.setParameter("struts_action",/etc/reports/add);

PortletId:
          To fetch the current portletId or portletName.

            portletDisplay.getId();
            portletDisplay.getPortletName();

plid (Portlet Layout id):
         We need to mention plid, based on this plid it will redirect that particular
         page.//for InterPortlet communication(IPC)

<%= LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, "/layoutName").getPlid() %>

OR

<%=themeDisplay.getPlid()%>

Lifecycle/PortletRequest:
         Two types of portlet request we can use here.

  1.   PortletRequest.RENDER_PHASE
  2.   PortletRequest.ACTION_PHASE
  3.   PortletRequest.EVENT_PHASE
  4.   PortletRequest.RESOURCE_PHASE
  5.   PortletRequest.LIFECYCLE_PHASE
Advertisements