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

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

Introduction

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

Prototype

public void setLifecycle(String lifecycle);

Source Link

Document

Sets the portlet lifecycle of this URL's target portlet.

Usage

From source file:com.hannikkala.thymeleaf.liferay.LiferayURLUtil.java

License:Open Source License

public static LiferayPortletURL createUrl(Map<String, Object> params, HttpServletRequest request) {

    long plid = parsePlid(params.remove("plid"), request);
    String portletName = getPortletName((String) params.remove("portletname"), request);
    String lifecycle = parseLifecycle((String) params.remove("lifecycle"));

    LiferayPortletURL portletURL = PortletURLFactoryUtil.create(request, portletName, plid, lifecycle);

    try {//from  www  . j a  v  a2s  .com
        portletURL.setWindowState(parseWindowState((String) params.remove("windowState")));
    } catch (WindowStateException ex) {
    }

    try {
        portletURL.setPortletMode(parsePortletMode((String) params.remove("portletMode")));
    } catch (PortletModeException ex) {
    }

    if (params.containsKey("action")) {
        String value = params.get("action") != null ? params.remove("action").toString() : "";
        portletURL.setParameter("javax.portlet.action", value, false);
        portletURL.setLifecycle(ACTION_PHASE);
    }

    for (Entry<String, Object> entry : params.entrySet()) {
        String value = entry.getValue() != null ? entry.getValue().toString() : "";
        portletURL.setParameter(entry.getKey(), value, true);
    }
    return portletURL;
}

From source file:com.liferay.portlet.documentlibrary.util.DLFileEntryIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {

    LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL;

    liferayPortletURL.setLifecycle(PortletRequest.ACTION_PHASE);

    try {// w w w .j av  a  2s  .  c o m
        liferayPortletURL.setWindowState(LiferayWindowState.EXCLUSIVE);
    } catch (WindowStateException wse) {
    }

    String fileEntryId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/document_library/get_file");
    portletURL.setParameter("fileEntryId", fileEntryId);

    Summary summary = createSummary(document, Field.TITLE, Field.CONTENT);

    summary.setMaxContentLength(200);
    summary.setPortletURL(portletURL);

    return summary;
}

From source file:com.liferay.portlet.documentlibrary.util.DLFolderIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {

    LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL;

    liferayPortletURL.setLifecycle(PortletRequest.ACTION_PHASE);

    try {//from  w w  w . java  2s  . c  om
        liferayPortletURL.setWindowState(LiferayWindowState.EXCLUSIVE);
    } catch (WindowStateException wse) {
    }

    String folderId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/document_library/view");
    portletURL.setParameter("folderId", folderId);

    Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION);

    summary.setMaxContentLength(200);
    summary.setPortletURL(portletURL);

    return summary;
}

From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {

    LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL;

    liferayPortletURL.setLifecycle(PortletRequest.ACTION_PHASE);

    try {//from   w  w  w.  j  a va2  s.c o m
        liferayPortletURL.setWindowState(LiferayWindowState.EXCLUSIVE);
    } catch (WindowStateException wse) {
    }

    String title = document.get(Field.TITLE);

    String content = snippet;

    if (Validator.isNull(snippet)) {
        content = StringUtil.shorten(document.get(Field.CONTENT), 200);
    }

    String fileEntryId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/document_library/get_file");
    portletURL.setParameter("fileEntryId", fileEntryId);

    return new Summary(title, content, portletURL);
}