1 Reply Latest reply on Dec 30, 2010 4:44 AM by Cato Eik

    Error when sendRedirect called in ActionMapping

    Cato Eik Newbie

      I'm using GateIn 3.1-FINAL on Tomcat with Spring 3.0.5-RELEASE


      Before getting to where I am, I've used ActionMapping's in my Spring Controller with setRenderParameter(xxx)


      But, when calling this ActionMapping, I've not called setRenderParameter (in this method) before calling sendRedirect(URL),

      and still I get an error:


      Caused by: java.lang.IllegalStateException: sendRedirect cannot be called after setPortletMode/setWindowState/setRenderParameter/setRenderParameters has been called previously
          at org.gatein.pc.portlet.impl.jsr168.api.StateAwareResponseImpl.checkRedirect(StateAwareResponseImpl.java:120)
          at org.gatein.pc.portlet.impl.jsr168.api.ActionResponseImpl.sendRedirect(ActionResponseImpl.java:63)


      Any suggestions to why?

      Can I clear previously setRenderParameter?


      When redirect within the portal, is there a more suited method than sendRedirect?



        • 1. Re: Error when sendRedirect called in ActionMapping
          Cato Eik Newbie

          After some frustration and digging around in debug, I found that StateAwareResponseImpl.setRenderParameter(name, value) was called when i "redirected" action call to another controller (applicationContext.xml):

          <bean id="parameterMappingInterceptor" class="org.springframework.web.portlet.handler.ParameterMappingInterceptor" />
              <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping">
                <property name="order" value="1"/>
                  <property name="interceptors">
                          <ref bean="parameterMappingInterceptor"/>
                  <property name="portletModeParameterMap">
                          <entry key="view">
                                  <entry key="myAction"><ref bean="myActionHandlerController" /></entry>


          The case was that I had a portlet (controller/view) where I, in the render, "redirected" to another non portlet controller/view, because this was a multistep flow where I would like to split the code for better overview.


          By "moving back" the action handling to the original controller, everything was OK.


          But for the case of redirecting within the portal, any comments/sugestions (or confirmation) to the method response.sendRedirect will be appreciated.