Search code examples
portletinterceptorspring-portlet-mvc

Portlet welcome page can appear in normal WindowState, other pages should appear in maximised WindowState only


I have a uPortal JSR-268 Spring MVC portlet, which has a welcome page. All links on the landing page render the next page in maximised mode, and this is true of all internal links.

What I want to do is render the welcome page if the user is on any other page, and changes the WindowState from maximised. This applies to RenderRequests only, I am not concerned about any other type of request here.

Users can change WindowState via the user interface using the "return to dashboard" link, by clicking the window buttons on the portal or, if they know what they are doing, by manipulating the URL.

I am able to identify requests for the welcome page by examining the request parameters.

I have tried

  • an interceptor, but all I seem to be able to do here is return false, which results in no content being rendered in the portlet. This is not acceptable.
  • throwing an error from the interceptor. This is a small improvement as I can show a custom error page, but it still does not allow me to render the welcome page.

It would also be acceptable to redirect to the originally requested page with WindowState set back to maximised. Portlets don't seem to support redirecting.

If I was dealing with ActionRequests, I could set a RenderParameter on the ActionResponse from the interceptor which would cause the welcome page to be rendered. However there doesn't seem to be an equivalent for RenderRequests. Am I missing something?


Solution

  • I ended up using a javax.portlet.filter.RenderFilter instead. The method signature looks like this

    public void doFilter(RenderRequest request, RenderResponse response,
       FilterChain chain) throws IOException, PortletException
    

    That gives me access to the renderRequest for a start. The next problem is that you can't set parameters in the RenderRequest.

    I solved this by extending RenderRequest and overriding getParameter so it would return the correct parameter to route the request to the correct controller. This allowed me to call the next link in the chain with the wrapped request.

    A bit messy but it works at least.