Example usage for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_REQUEST

List of usage examples for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_REQUEST

Introduction

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

Prototype

String JAVAX_PORTLET_REQUEST

To view the source code for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_REQUEST.

Click Source Link

Usage

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

License:Open Source License

private static String _getPortletName(HttpServletRequest request) {
    PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

    if (portletRequest == null) {
        return null;
    }// w  w w. j  a  va 2 s  . c o m

    LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) request
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    return liferayPortletConfig.getPortletId();
}

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

License:Open Source License

@Override
public int doStartTag() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    String lifecycle = (String) request.getAttribute(PortletRequest.LIFECYCLE_PHASE);

    PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    if (portletConfig != null) {
        pageContext.setAttribute("portletConfig", portletConfig);
        pageContext.setAttribute("portletName", portletConfig.getPortletName());
    }// ww w  . j av  a 2 s.  c om

    PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

    if (portletRequest != null) {
        pageContext.setAttribute("liferayPortletRequest", PortalUtil.getLiferayPortletRequest(portletRequest));

        String portletRequestAttrName = null;

        if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
            portletRequestAttrName = "actionRequest";
        } else if (lifecycle.equals(PortletRequest.EVENT_PHASE)) {
            portletRequestAttrName = "eventRequest";
        } else if (lifecycle.equals(PortletRequest.RENDER_PHASE)) {
            portletRequestAttrName = "renderRequest";
        } else if (lifecycle.equals(PortletRequest.RESOURCE_PHASE)) {
            portletRequestAttrName = "resourceRequest";
        }

        pageContext.setAttribute(portletRequestAttrName, portletRequest);

        PortletPreferences portletPreferences = portletRequest.getPreferences();

        pageContext.setAttribute("portletPreferences", portletPreferences);
        pageContext.setAttribute("portletPreferencesValues", portletPreferences.getMap());

        PortletSession portletSession = portletRequest.getPortletSession();

        pageContext.setAttribute("portletSession", portletSession);

        try {
            pageContext.setAttribute("portletSessionScope", portletSession.getAttributeMap());
        } catch (IllegalStateException ise) {
        }
    }

    PortletResponse portletResponse = (PortletResponse) request
            .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);

    if (portletResponse != null) {
        pageContext.setAttribute("liferayPortletResponse",
                PortalUtil.getLiferayPortletResponse(portletResponse));

        String portletResponseAttrName = null;

        if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
            portletResponseAttrName = "actionResponse";
        } else if (lifecycle.equals(PortletRequest.EVENT_PHASE)) {
            portletResponseAttrName = "eventResponse";
        } else if (lifecycle.equals(PortletRequest.RENDER_PHASE)) {
            portletResponseAttrName = "renderResponse";
        } else if (lifecycle.equals(PortletRequest.RESOURCE_PHASE)) {
            portletResponseAttrName = "resourceResponse";
        }

        pageContext.setAttribute(portletResponseAttrName, portletResponse);
    }

    return SKIP_BODY;
}

From source file:com.liferay.taglib.portletext.RuntimeTag.java

License:Open Source License

public static void doTag(String portletName, String queryString, String defaultPreferences,
        PageContext pageContext, ServletContext servletContext, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    if (pageContext != null) {
        response = new PipingServletResponse(response, pageContext.getOut());
    }/*from   w  ww  . jav a 2s  .  c  o  m*/

    PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

    RenderRequest renderRequest = null;

    if ((portletRequest != null) && (portletRequest instanceof RenderRequest)) {

        renderRequest = (RenderRequest) portletRequest;
    }

    PortletResponse portletResponse = (PortletResponse) request
            .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);

    RenderResponse renderResponse = null;

    if ((portletResponse != null) && (portletResponse instanceof RenderResponse)) {

        renderResponse = (RenderResponse) portletResponse;
    }

    String portletId = portletName;

    try {
        request.setAttribute(WebKeys.RENDER_PORTLET_RESOURCE, Boolean.TRUE);

        if (Validator.isNotNull(defaultPreferences)) {
            PortletPreferencesFactoryUtil.getPortletSetup(request, portletId, defaultPreferences);
        }

        RuntimePortletUtil.processPortlet(servletContext, request, response, renderRequest, renderResponse,
                portletId, queryString, true);

        Set<String> runtimePortletIds = (Set<String>) request.getAttribute(WebKeys.RUNTIME_PORTLET_IDS);

        if (runtimePortletIds == null) {
            runtimePortletIds = new HashSet<String>();
        }

        runtimePortletIds.add(portletName);

        request.setAttribute(WebKeys.RUNTIME_PORTLET_IDS, runtimePortletIds);
    } finally {
        request.removeAttribute(WebKeys.RENDER_PORTLET_RESOURCE);
    }
}

From source file:com.liferay.taglib.ui.ErrorTag.java

License:Open Source License

@Override
public int doEndTag() throws JspException {
    try {/*from   w ww .j  a  v  a  2  s. c  o  m*/
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

        PortletRequest portletRequest = (PortletRequest) request
                .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

        boolean includeEndPage = false;

        if (Validator.isNull(_key)) {
            if (!SessionErrors.isEmpty(portletRequest)) {
                includeEndPage = true;
            }
        } else {
            if (SessionErrors.contains(portletRequest, _key)) {
                includeEndPage = true;
            }
        }

        if (includeEndPage) {
            PortalIncludeUtil.include(pageContext, getEndPage());

            String errorMarkerKey = (String) request.getAttribute("liferay-ui:error-marker:key");
            String errorMarkerValue = (String) request.getAttribute("liferay-ui:error-marker:value");

            if (Validator.isNotNull(errorMarkerKey) && Validator.isNotNull(errorMarkerValue)) {

                request.setAttribute(errorMarkerKey, errorMarkerValue);
            }
        }

        return EVAL_PAGE;
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:com.liferay.taglib.ui.ErrorTag.java

License:Open Source License

@Override
public int doStartTag() throws JspException {
    try {// ww w .  j  a  v a2s .  c  o  m
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

        PortletRequest portletRequest = (PortletRequest) request
                .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

        request.setAttribute("liferay-ui:error:key", _key);
        request.setAttribute("liferay-ui:error:message", _message);
        request.setAttribute("liferay-ui:error:rowBreak", _rowBreak);
        request.setAttribute("liferay-ui:error:translateMessage", String.valueOf(_translateMessage));

        if (Validator.isNotNull(_message)) {
            return SKIP_BODY;
        }

        if (SessionErrors.contains(portletRequest, _key)) {
            Object value = null;

            if (_exception != null) {
                value = SessionErrors.get(portletRequest, _exception.getName());
            } else {
                value = SessionErrors.get(portletRequest, _key);
            }

            PortalIncludeUtil.include(pageContext, getStartPage());

            if (value != null) {
                pageContext.setAttribute("errorException", value);
            }

            return EVAL_BODY_INCLUDE;
        }

        return SKIP_BODY;
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:com.liferay.taglib.ui.SearchContainerTag.java

License:Open Source License

@Override
public int doStartTag() throws JspException {
    try {//from ww w  .j  ava  2s  .  c om
        HttpServletRequest request = getServletRequest();

        PortletRequest portletRequest = (PortletRequest) request
                .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
        PortletResponse portletResponse = (PortletResponse) request
                .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);

        if (_iteratorURL == null) {
            _iteratorURL = ((MimeResponse) portletResponse).createRenderURL();
        }

        if (_searchContainer == null) {
            _searchContainer = new SearchContainer<R>(portletRequest, _displayTerms, _searchTerms,
                    getCurParam(), getDelta(), _iteratorURL, null, _emptyResultsMessage);
        }

        _searchContainer.setDeltaConfigurable(_deltaConfigurable);
        _searchContainer.setId(_id);

        if (_headerNames != null) {
            _searchContainer.setHeaderNames(_headerNames);
        }

        _searchContainer.setHover(_hover);

        if (Validator.isNotNull(_orderByColParam)) {
            _searchContainer.setOrderByColParam(_orderByColParam);
        }

        if (Validator.isNotNull(_orderByCol)) {
            _searchContainer.setOrderByCol(_orderByCol);
        }

        if (_orderByComparator != null) {
            _searchContainer.setOrderByComparator(_orderByComparator);
        }

        if (Validator.isNotNull(_orderByTypeParam)) {
            _searchContainer.setOrderByTypeParam(_orderByTypeParam);
        }

        if (Validator.isNotNull(_orderByType)) {
            _searchContainer.setOrderByType(_orderByType);
        }

        if (_rowChecker != null) {
            _searchContainer.setRowChecker(_rowChecker);
        }

        pageContext.setAttribute(_var, _searchContainer);

        return EVAL_BODY_INCLUDE;
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:com.liferay.tool.datamanipulator.context.RequestContext.java

License:Open Source License

public PortletRequest getRequest() {
    return (PortletRequest) _uploadRequest.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
}

From source file:com.liferay.trash.taglib.servlet.taglib.UndoTag.java

License:Open Source License

private Map<String, Object> _getData() {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String key = portletDisplay.getId() + SessionMessages.KEY_SUFFIX_DELETE_SUCCESS_DATA;

    if (!SessionMessages.contains(portletRequest, key)) {
        return null;
    }/*from w  w w . j  a  v  a2 s  .co  m*/

    return (HashMap<String, Object>) SessionMessages.get(portletRequest, key);
}

From source file:com.liferay.user.groups.admin.item.selector.web.internal.display.context.UserGroupItemSelectorViewDisplayContext.java

License:Open Source License

public UserGroupItemSelectorViewDisplayContext(UserGroupLocalService userGroupLocalService,
        UsersAdmin usersAdmin, HttpServletRequest httpServletRequest, PortletURL portletURL,
        String itemSelectedEventName) {

    _userGroupLocalService = userGroupLocalService;
    _usersAdmin = usersAdmin;/*from  w  ww  . j  a v a  2 s  .  c o  m*/
    _httpServletRequest = httpServletRequest;
    _portletURL = portletURL;
    _itemSelectedEventName = itemSelectedEventName;

    _renderRequest = (RenderRequest) httpServletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
    _renderResponse = (RenderResponse) httpServletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);
}

From source file:com.liferay.users.admin.item.selector.web.internal.display.context.UserItemSelectorViewDisplayContext.java

License:Open Source License

public UserItemSelectorViewDisplayContext(UserLocalService userLocalService, UsersAdmin usersAdmin,
        HttpServletRequest httpServletRequest, PortletURL portletURL, String itemSelectedEventName) {

    _userLocalService = userLocalService;
    _usersAdmin = usersAdmin;//ww  w.  j av  a  2  s  .  c  o  m
    _httpServletRequest = httpServletRequest;
    _portletURL = portletURL;
    _itemSelectedEventName = itemSelectedEventName;

    _portletRequest = (PortletRequest) httpServletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
    _renderResponse = (RenderResponse) httpServletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);
}