3 Replies Latest reply on Aug 8, 2006 12:27 PM by soshah

    sendRedirect and setRenderParameter

    pedrosacosta

      In the javadoc of the Portal the folowwing methods say:

      "sendRedirect

      The sendRedirect method can not be invoked after any of the following methods of the ActionResponse interface has been called:

      * setPortletMode
      * setWindowState
      * setRenderParameter
      * setRenderParameters "

      "setRenderParameter

      Throws:

      java.lang.IllegalStateException - if the method is invoked after sendRedirect has been called."


      So, how can i use the setRenderParameter and sendRedirect methods at the same time?

      Thanks,
      Pedro

        • 1. Re: sendRedirect and setRenderParameter

          Why would you want to do that? It doesnt make sense to set a render param and then redirect to some foreign url.

          • 2. Re: sendRedirect and setRenderParameter
            pedrosacosta

            In the portal that i'm building, i'm using attributes to send information from the java classes to the jsp files. For example, have a jsp that shows the name of the user logged in.

            But, in other use cases, like submit a form, i want to show messages to the user like "The registration submitted sucessfully". But this message must dissappear if i do another action that follow the submit action.

            I thought to put this variables/attributes in session, but i had a problem. The variables remains in session, and in the sequence of the pageflow, it is very difficult to remove the attributes in all cases of the pageflow of my portlet. My portlet has many pages that use the same portlet, but for different cases.

            So, i thought to use renderParameter as a substiture to setAttribute. I thought that the renderParameter value dissappeared if i render the same page again.

            For example, when i render a page, i set a message with renderParameter. If i re-render the page, the parameter would dissapear.

            But, i'm seeing that it's not possible.

            So, how can i set values that won't remain in session?

            Thanks,
            Pedro


            • 3. Re: sendRedirect and setRenderParameter
              soshah

              Pedro-

              As an alternate approach for redirect, you can still set the render parameter for your view and forward to the appropriate view.


              Then you can use a javascript redirect to get to the next screen instead of using the sendRedirect method.

              sample code for the view:

              <form name="redirect" action="location to go to" method="post"/>
              <!-- perform a sendRedirect to the above resource -->
              <script type="text/javascript" language="javascript">
               document.redirect.submit();
              </script>
              


              Thanks
              Sohil