Search in sources :

Example 16 with PortletSession

use of javax.portlet.PortletSession in project uPortal by Jasig.

the class RenderPortletTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    //From portlet:defineObjects
    final RenderRequest renderRequest = (RenderRequest) this.pageContext.getAttribute("renderRequest");
    final RenderResponse renderResponse = (RenderResponse) this.pageContext.getAttribute("renderResponse");
    final PortletDelegationLocator portletDelegationLocator = (PortletDelegationLocator) renderRequest.getAttribute(PortletDelegationLocator.PORTLET_DELECATION_LOCATOR_ATTR);
    final String sessionKey = this.sessionKeyPrefix + this.fname;
    final PortletSession portletSession = renderRequest.getPortletSession();
    IPortletWindowId portletWindowId = (IPortletWindowId) portletSession.getAttribute(sessionKey);
    final PortletDelegationDispatcher portletDelegationDispatcher;
    final DelegateState delegateState;
    //No id in session, create a new dispatcher
    if (portletWindowId == null) {
        portletDelegationDispatcher = portletDelegationLocator.createRequestDispatcher(renderRequest, this.fname);
        portletWindowId = portletDelegationDispatcher.getPortletWindowId();
        portletSession.setAttribute(sessionKey, portletWindowId);
        final PortletMode portletMode = PortletUtils.getPortletMode(this.portletMode);
        final WindowState windowState = PortletUtils.getWindowState(this.windowState);
        delegateState = new DelegateState(portletMode, windowState);
    } else //id in session, get the old dispatcher
    {
        portletDelegationDispatcher = portletDelegationLocator.getRequestDispatcher(renderRequest, portletWindowId);
        delegateState = null;
    }
    final DelegationRequest delegationRequest = new DelegationRequest();
    delegationRequest.setDelegateState(delegateState);
    //Setup base for portlet URLs
    delegationRequest.setParentPortletMode(this.parentUrlMode);
    delegationRequest.setParentWindowState(this.parentUrlState);
    delegationRequest.setParentParameters(this.parentUrlParameters);
    final JspWriter out = this.pageContext.getOut();
    try {
        portletDelegationDispatcher.doRender(renderRequest, renderResponse, delegationRequest, new JspWriterPortletOutputHandler(out, renderResponse));
    } catch (IOException e) {
        throw new JspException("Failed to execute delegate render on portlet '" + this.fname + "'", e);
    }
    return Tag.EVAL_PAGE;
}
Also used : WindowState(javax.portlet.WindowState) RenderRequest(javax.portlet.RenderRequest) DelegateState(org.apereo.portal.api.portlet.DelegateState) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) PortletMode(javax.portlet.PortletMode) JspException(javax.servlet.jsp.JspException) PortletSession(javax.portlet.PortletSession) PortletDelegationDispatcher(org.apereo.portal.api.portlet.PortletDelegationDispatcher) RenderResponse(javax.portlet.RenderResponse) PortletDelegationLocator(org.apereo.portal.api.portlet.PortletDelegationLocator) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) DelegationRequest(org.apereo.portal.api.portlet.DelegationRequest)

Aggregations

PortletSession (javax.portlet.PortletSession)16 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 PortletRequest (javax.portlet.PortletRequest)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpSession (javax.servlet.http.HttpSession)2 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)2 SearchRequest (org.apereo.portal.search.SearchRequest)2 SearchResult (org.apereo.portal.search.SearchResult)2 Cache (com.google.common.cache.Cache)1 Enumeration (java.util.Enumeration)1 Event (javax.portlet.Event)1 PortletMode (javax.portlet.PortletMode)1 PortletPreferences (javax.portlet.PortletPreferences)1