Example usage for com.liferay.portal.kernel.util PortalUtil getPortletTitle

List of usage examples for com.liferay.portal.kernel.util PortalUtil getPortletTitle

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PortalUtil getPortletTitle.

Prototype

public static String getPortletTitle(Portlet portlet, ServletContext servletContext, Locale locale) 

Source Link

Usage

From source file:com.liferay.application.list.taglib.servlet.taglib.PanelAppTag.java

License:Open Source License

@Override
protected void setAttributes(HttpServletRequest request) {
    boolean active = false;

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    if (_active != null) {
        active = _active.booleanValue();
    } else {//ww w.  ja v  a2  s  .  c om
        active = Objects.equals(themeDisplay.getPpid(), _panelApp.getPortletId());
    }

    request.setAttribute("liferay-application-list:panel-app:active", active);

    if (_data == null) {
        _data = new HashMap<>();
    }

    if (Validator.isNull(_label) && (_panelApp != null)) {
        Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(),
                _panelApp.getPortletId());

        _label = PortalUtil.getPortletTitle(portlet, servletContext, themeDisplay.getLocale());

        if (!_data.containsKey("qa-id")) {
            _data.put("qa-id", "app");
        }
    }

    if (!_data.containsKey("title")) {
        _data.put("title", _label);
    }

    request.setAttribute("liferay-application-list:panel-app:data", _data);

    if (Validator.isNull(_id)) {
        _id = "portlet_" + _panelApp.getPortletId();
    }

    request.setAttribute("liferay-application-list:panel-app:id", _id);

    request.setAttribute("liferay-application-list:panel-app:label", _label);

    int notificationsCount = 0;

    if (_panelApp != null) {
        notificationsCount = _panelApp.getNotificationsCount(themeDisplay.getUser());
    }

    request.setAttribute("liferay-application-list:panel-app:notificationsCount", notificationsCount);

    request.setAttribute("liferay-application-list:panel-app:panelApp", _panelApp);

    if (Validator.isNull(_url) && (_panelApp != null)) {
        PortletURL portletURL = null;

        try {
            portletURL = _panelApp.getPortletURL(request);
        } catch (PortalException pe) {
            _log.error("Unable to get portlet URL", pe);
        }

        _url = portletURL.toString();
    }

    request.setAttribute("liferay-application-list:panel-app:url", _url);
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static String getTitle(Portlet portlet, RenderRequest renderRequest) throws Exception {

    ServletContext servletContext = (ServletContext) renderRequest.getAttribute(WebKeys.CTX);

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);

    PortletPreferences portletSetup = getLayoutPortletSetup(renderRequest, portlet);

    portletSetup = getPortletSetup(request, renderRequest.getPreferences(), portletSetup);

    String title = PortletConfigurationUtil.getPortletTitle(portletSetup, themeDisplay.getLanguageId());

    if (Validator.isNull(title)) {
        title = PortalUtil.getPortletTitle(portlet, servletContext, themeDisplay.getLocale());
    }/*from  www .  j  a  v a  2  s . c  o  m*/

    return title;
}