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.

Handling Minimized

GenericPortlet

If your portlet extends GenericPortlet it is fine. GenericPortlet's implementation of the render method delegates first to doDispatch which checks the WindowState and simply returns if the portlet is minimized. So 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>

Additional References

 

Having problems with these instructions?

Please send us feedback at uportal-user@lists.ja-sig.org