Patrick,

Sorry for the slow response.  The sendRedirect issue is a serious pain and does require some careful handling so that it can work.

You are correct that the portlet spec makes it illegal to call sendRedirect after certain other methods, like setRenderParameter, have been called.

However, it is possible to use sendRedirect with Spring Portlet MVC.  In fact the sample code includes an example portlet that will do a redirect to an aribitrary URL.  Take a look at it for more details.

So, this means that, either in the Spring Portlet code you are using or in your own code, something that breaks sendRedirect is being called before you can issue the redirect.  Most likely this means either the Controller or an Interceptor is doing this.

First, what specific Controller class does your controller decend from?  If it is an AbstractController, then the issue must be elsewhere since AbstractController itself never makes any calls to setRenderParameter (or the other methods that break sendRedirect).  If your controller descends from AbstractFormController, SimpleFormController, or AbstractWizardFormController, then you must set the 'redirectAction' property to true on this controller so that setRenderParameter will not be called by the AbstractFormController code.

Second, are you using the ParameterMappingInterceptor with this portlet?  If so, this will break redirect since the whole point of this Interceptor is to automatically propagate the parameter you are using for your mapping from the action phase to the render phase.  If so, remove this Interceptor and propagate the parameter manually in your Controllers when you do need it.  Or create a different version of the Interceptor that propagates it during the afterCompletion method instead of the preHandle method -- although this will prevent you from changing the parameter in your Controller, if desired.

I hope that helps you find the issue.  Let me know how it goes.

John



Patrick Huber wrote:
Hi again

I've been investigating a little bit more in the mean time and it's a
"bug" in spring portlet. The Portlet Spec, Chapter PLT.12.2.1 (page
50), defines the exact behaviour of sendRedirect (compare with the
details in my first mail).

Is it possible to work around the problem?

If there is a place to post an official issue, I'll happily open an
issue there. It's just, the springframework jira doesn't appear to be
the right place since spring-portlet is not listed under the springweb
module.

regards
Patrick


2005/12/6, Patrick Huber <[EMAIL PROTECTED]>:
  
Hello John

I hope you don't mind if I send you an e-mail directly. I've found
this address on a mailing list.

I am using spring-portlet and it works quite nice. But now I've come
across a problem: I have a small test Portlet which manages a list of
bookmarks. I intended to count the number of times someone clicks a
link and display the list with a descending click count. So to do
this, I added another controller and in the
handleActionRequestInternal method, I increase the click count and do
a response.sendRedirect.

When I call sendRedirect, Pluto complains like this:
java.lang.IllegalStateException: Can't invoke sendRedirect() after
certain methods have been called
        at org.apache.pluto.core.impl.ActionResponseImpl.sendRedirect(ActionResponseImpl.java:142)
        at net.swisstech.portlet.bookmark.web.controller.BookmarkVisitController.handleActionRequestInternal(BookmarkVisitController.java:38)
        at org.springframework.web.portlet.mvc.AbstractController.handleActionRequest(AbstractController.java:221)
        at org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter.handleAction(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.portlet.DispatcherPortlet.doActionDispatch(DispatcherPortlet.java:779)
        at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:702)
        at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:431)
        at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:408)
        at org.apache.pluto.core.PortletServlet.dispatch(PortletServlet.java:171)
        at org.apache.pluto.core.PortletServlet.doGet(PortletServlet.java:113)

So I looked into plutos ActionRespnseImpl. It keeps a flag which is
flipped on certain calls like for example setRenderParameter.
ParameterMappingInterceptor does call that method in preHandle on line
73. So trying to send a redirect will then throw the above exception.

Is it possible to change the spring portlet code so redirecting can
work? Or is this a bug in plutos ActionResponseImpl?

Could you please comment on this issue?

Thank you
Patrick

--
"I love deadlines. I like the whooshing sound they make as they fly
by." -- Douglas Adams

    


--
"I love deadlines. I like the whooshing sound they make as they fly
by." -- Douglas Adams
  

Reply via email to