Portlet WindowStates

Supported WindowStates

State

Use

Normal

Portlet is rendered on a tab alongside other portlets

Maximized

The portlet is shown by itself and given a larger amount of screen real estate. Identical to uPortal "focused" concept.

Minimized

Render either no content, or a smaller amount of content than the normal mode. Similar to uPortal "minimized" concept.

Exclusive

Gives the portlet full control over the request and response. This mode may be used to implement file downloads.

Changing the WindowState

Developers may change the WindowState via either a link or via Java code.

Changing WindowState via HTML
    <portlet:actionURL windowState="maximized"/>
Changing WindowState via Java
    actionResponse.setWindowState(WindowState.MAXIMIZED);

Handling the Minimized WindowState

Contrary to many developer's assumptions a portlet can render content when minimized. The portal still calls Portlet.render(RenderRequest, RenderResponse) with the WindowState set to MINIMIZED.

GenericPortlet

If your portlet extends GenericPortlet no content will be displayed when the portlet is minimized. GenericPortlet's implementation of the render method delegates first to doDispatch which checks the WindowState and simply returns if the portlet is minimized. In this case, unless your portlet has overriden doDispatch, Minimized state handling is taken care of for you.

Spring Class-Based Controllers

The Spring AbstractController class defaults to not rendering when the portlet is minimized. If your portlet has this class in its class hierarchy Minimized state handling is taken care of for you.

Spring Web-Flow & Annotation Driving Controllers

Spring Web-Flow and the Annotation Driven controllers do not have any special handling for the MINIMIZED WindowState. This means the default behavior is the portlets render normally whenever they are minimized. To address this a HandlerInterceptor to skip rendering when minimized. The handler interceptor to accomplish this is listed below along with the Spring Bean's configuration snippets for both WebFlow and Annotation Based Controllers

Minimized Handler Interceptor
package org.jasig.portlet.web;

import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.WindowState;

import org.springframework.web.portlet.handler.HandlerInterceptorAdapter;

public class MinimizedStateHandlerInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception {
        if (WindowState.MINIMIZED.equals(request.getWindowState())) {
            return false;
        }
        
        return true;
    }
}
Web Flow Interceptor Configuration
<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
    <property name="interceptors"><bean class="org.jasig.portlet.web.MinimizedStateHandlerInterceptor"/></property>
    <property name="portletModeMap">
        <map>
            <entry key="view">
                <bean class="org.jasig.portal.portlets.flow.ParamaterizableFlowHandler">
                    <property name="flowId" value="my-application-flow" />
                </bean>
            </entry>
        </map>
    </property>
</bean>
Annotation Based Controller Configuration
<context:annotation-config/>
<context:component-scan base-package="org.jasig.portlet.web"/>

<bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    <property name="interceptors"><bean class="org.jasig.portlet.web.MinimizedStateHandlerInterceptor"/></property>
</bean>