Example usage for com.liferay.portal.kernel.util WebKeys RENDER_PORTLET_RESOURCE

List of usage examples for com.liferay.portal.kernel.util WebKeys RENDER_PORTLET_RESOURCE

Introduction

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

Prototype

String RENDER_PORTLET_RESOURCE

To view the source code for com.liferay.portal.kernel.util WebKeys RENDER_PORTLET_RESOURCE.

Click Source Link

Usage

From source file:com.liferay.portlet.layoutconfiguration.util.velocity.TemplateProcessor.java

License:Open Source License

public String processPortlet(String portletId) throws Exception {
    try {/*from  ww  w  .  j  a v  a2 s .  co m*/
        _request.setAttribute(WebKeys.RENDER_PORTLET_RESOURCE, Boolean.TRUE);

        RuntimeLogic logic = new PortletLogic(_servletContext, _request, _response, portletId);

        return logic.processContent(new HashMap<String, String>());
    } finally {
        _request.removeAttribute(WebKeys.RENDER_PORTLET_RESOURCE);
    }
}

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());
    }/* ww  w.j a  va 2  s.  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);
    }
}