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

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

Introduction

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

Prototype

public void setPortletId(String portletId);

Source Link

Document

Sets the ID of the target portlet.

Usage

From source file:com.liferay.portlet.layoutconfiguration.util.xml.ActionURLLogic.java

License:Open Source License

@Override
public String processXML(String xml) throws Exception {
    Document doc = SAXReaderUtil.read(xml);

    Element root = doc.getRootElement();

    LiferayPortletResponse liferayPortletResponse = PortalUtil.getLiferayPortletResponse(_renderResponseImpl);
    LiferayPortletURL liferayPortletURL = liferayPortletResponse.createLiferayPortletURL(getLifecycle());

    String portletId = root.attributeValue("portlet-name");

    if (portletId != null) {
        portletId = PortalUtil.getJsSafePortletId(portletId);

        liferayPortletURL.setPortletId(portletId);
    }//from   www  .j  a va2s  .  c o m

    for (int i = 1;; i++) {
        String paramName = root.attributeValue("param-name-" + i);
        String paramValue = root.attributeValue("param-value-" + i);

        if ((paramName == null) || (paramValue == null)) {
            break;
        }

        liferayPortletURL.setParameter(paramName, paramValue);
    }

    return liferayPortletURL.toString();
}

From source file:com.liferay.portlet.PortletURLUtil.java

License:Open Source License

public static PortletURL clone(LiferayPortletURL liferayPortletURL, String lifecycle, MimeResponse mimeResponse)
        throws PortletException {

    LiferayPortletURL newURLImpl = null;

    if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
        newURLImpl = (LiferayPortletURL) mimeResponse.createActionURL();
    } else if (lifecycle.equals(PortletRequest.RENDER_PHASE)) {
        newURLImpl = (LiferayPortletURL) mimeResponse.createRenderURL();
    }// ww  w.  j a  v a 2s .  c  o  m

    newURLImpl.setPortletId(liferayPortletURL.getPortletId());

    WindowState windowState = liferayPortletURL.getWindowState();

    if (windowState != null) {
        newURLImpl.setWindowState(windowState);
    }

    PortletMode portletMode = liferayPortletURL.getPortletMode();

    if (portletMode != null) {
        newURLImpl.setPortletMode(portletMode);
    }

    newURLImpl.setParameters(liferayPortletURL.getParameterMap());

    return newURLImpl;
}