Example usage for com.liferay.portal.kernel.portlet LiferayPortletURL setRefererPlid

List of usage examples for com.liferay.portal.kernel.portlet LiferayPortletURL setRefererPlid

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet LiferayPortletURL setRefererPlid.

Prototype

public void setRefererPlid(long refererPlid);

Source Link

Document

Sets the referer layout ID.

Usage

From source file:com.liferay.taglib.portlet.ActionURLTag.java

License:Open Source License

public static void doTag(String lifecycle, String windowState, String portletMode, String var, String varImpl,
        Boolean secure, Boolean copyCurrentRenderParameters, Boolean escapeXml, String name, String resourceID,
        String cacheability, long plid, long refererPlid, String portletName, Boolean anchor, Boolean encrypt,
        long doAsGroupId, long doAsUserId, Boolean portletConfiguration, Map<String, String[]> params,
        PageContext pageContext) throws Exception {

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    if (portletName == null) {
        portletName = _getPortletName(request);
    }/*from   w  w  w . ja va 2 s  .  co m*/

    LiferayPortletURL liferayPortletURL = _getLiferayPortletURL(request, plid, portletName, lifecycle);

    if (liferayPortletURL == null) {
        _log.error("Render response is null because this tag is not being "
                + "called within the context of a portlet");

        return;
    }

    if (Validator.isNotNull(windowState)) {
        liferayPortletURL.setWindowState(WindowStateFactory.getWindowState(windowState));
    }

    if (Validator.isNotNull(portletMode)) {
        liferayPortletURL.setPortletMode(PortletModeFactory.getPortletMode(portletMode));
    }

    if (secure != null) {
        liferayPortletURL.setSecure(secure.booleanValue());
    } else {
        liferayPortletURL.setSecure(PortalUtil.isSecure(request));
    }

    if (copyCurrentRenderParameters != null) {
        liferayPortletURL.setCopyCurrentRenderParameters(copyCurrentRenderParameters.booleanValue());
    }

    if (escapeXml != null) {
        liferayPortletURL.setEscapeXml(escapeXml.booleanValue());
    }

    if (lifecycle.equals(PortletRequest.ACTION_PHASE) && Validator.isNotNull(name)) {

        liferayPortletURL.setParameter(ActionRequest.ACTION_NAME, name);
    }

    if (resourceID != null) {
        liferayPortletURL.setResourceID(resourceID);
    }

    if (cacheability != null) {
        liferayPortletURL.setCacheability(cacheability);
    }

    if (refererPlid > LayoutConstants.DEFAULT_PLID) {
        liferayPortletURL.setRefererPlid(refererPlid);
    }

    if (anchor != null) {
        liferayPortletURL.setAnchor(anchor.booleanValue());
    }

    if (encrypt != null) {
        liferayPortletURL.setEncrypt(encrypt.booleanValue());
    }

    if (doAsGroupId > 0) {
        liferayPortletURL.setDoAsGroupId(doAsGroupId);
    }

    if (doAsUserId > 0) {
        liferayPortletURL.setDoAsUserId(doAsUserId);
    }

    if ((portletConfiguration != null) && portletConfiguration.booleanValue()) {

        String returnToFullPageURL = ParamUtil.getString(request, "returnToFullPageURL");
        String portletResource = ParamUtil.getString(request, "portletResource");
        String previewWidth = ParamUtil.getString(request, "previewWidth");

        liferayPortletURL.setParameter("struts_action", "/portlet_configuration/edit_configuration");
        liferayPortletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
        liferayPortletURL.setParameter("portletResource", portletResource);
        liferayPortletURL.setParameter("previewWidth", previewWidth);
    }

    if (params != null) {
        MapUtil.merge(liferayPortletURL.getParameterMap(), params);

        liferayPortletURL.setParameters(params);
    }

    String portletURLToString = liferayPortletURL.toString();

    if (Validator.isNotNull(var)) {
        pageContext.setAttribute(var, portletURLToString);
    } else if (Validator.isNotNull(varImpl)) {
        pageContext.setAttribute(varImpl, liferayPortletURL);
    } else {
        JspWriter jspWriter = pageContext.getOut();

        jspWriter.write(portletURLToString);
    }
}