5 Replies Latest reply on Sep 10, 2007 9:41 AM by atao

    regarding Redirect.captureCurrentView()

    mnrz

      hello

      I want to navigate from a page to my error page when an exception occurs, and after going to error page, the user is able to click on "back" button to go back to last page.

      I am using Redirect.instance().captureCurrentView() and in my ErrorAction bean in its back() method I called Redirect.instance().returnToCapturedView() but it doesn't work. Am I doing wrong?

      thanks

        • 1. Re: regarding Redirect.captureCurrentView()
          atao

          Redirect.instance().captureCurrentView() works with the viewId of the required view. See login pages in seam-gen to get the idea.

          You need to use a page parameter. See (in french): http://wiki.objetdirect.com/wiki/index.php?title=Navigation_avec_Seam

          • 2. Re: regarding Redirect.captureCurrentView()
            mnrz

            as I read in javadoc it is stated:

            captureCurrentView():
            Capture the view id and page parameters from the current request and squirrel them away so we can return here later in the conversation.

            and

            returnToCapturedView():
            Redirect to the captured view, and end any conversation that began in captureCurrentView().


            I think it should work as they described

            • 3. Re: regarding Redirect.captureCurrentView()
              atao

               


              I think it should work as they described


              In fact it does. But I needed some times before to get it: the key words are "current request". The viewId is the one of the request, i.e. of the required view, not of the requiring view.

              You can switch from the current request to a new one and then come back to this request, but not to the point which raised this request.

              Login in seam-gen is a good example to get it.

              • 4. Re: regarding Redirect.captureCurrentView()
                mnrz

                well, I checked the seam-gen but its login page and its authenticator is very simple without any use of "Redirect". could you give me the file name you are meant?

                • 5. Re: regarding Redirect.captureCurrentView()
                  atao

                  In application generated by seam-gen, there is in components.xml:

                   <event type="org.jboss.seam.notLoggedIn">
                   <action expression="#{redirect.captureCurrentView}"/>
                   </event>
                   <event type="org.jboss.seam.postAuthenticate">
                   <action expression="#{redirect.returnToCapturedView}"/>
                   </event>
                  


                  and in pages.xml:
                   <exception class="org.jboss.seam.security.NotLoggedInException">
                   <redirect view-id="/login.xhtml">
                   <message>#{messages['org.jboss.seam.security.NotLoggedInException']}</message>
                   </redirect>
                   </exception>
                  
                  


                  The event org.jboss.seam.notLoggedIn is raised by Pages.notLoggedIn which is called by Pages.redirectToLoginView just before going to the Login view.

                  And the event org.jboss.seam.postAuthenticate is raised by Identity.postAuthenticate