6 Replies Latest reply on Mar 16, 2006 6:34 AM by Gavin King

    Nesting the Login Conversation

    Tim Brewer Newbie

      Hi,

      I'm attempting to create a nested login conversation based on the DVD Store example. Rather than going to a fixed page after login I would like the previous conversation to continue as if the user was already logged in.

      e.g.

      Find List of Jobs -> Select Job -> Apply Apply
       -> Login ->
      


      So the login process (& possibly the register new user process) are integrated into the apply process if the user is not logged on.

      From the documentation this seems possible, but I'm not clear on how to return the user to the apply process. My login() method ends the nested conversation and returns a fixed outcome, but really should return the apply outcome (or which ever outcome was in progress when the nested conversation started).

      Is there some way of obtaining the 'parent' outcome or automatically returning the user to the parent process ?

      Many thanks,

      Tim.

        • 1. Re: Nesting the Login Conversation
          Christian Bauer Master

          I had asked myself a similar question last week, we are basically looking for a way to do History and History* (UI statechart stuff we talked about in the early days of Seam).

          • 2. Re: Nesting the Login Conversation
            Tim Brewer Newbie

            Well I've done it, but only by storing the outcome in the session context and then firing it when the login or register process is complete.

            Surely this sort of process is what nested conversations are made for ?

            Cheers,

            Tim.

            • 3. Re: Nesting the Login Conversation
              Gavin King Master

              Have you looked at how the issue tracker demo handles the login challenge? I think that is pretty elegant.

              (It uses Conversation.redirect().)

              • 4. Re: Nesting the Login Conversation
                Gavin King Master

                 

                "tim.brewer@iblocks.co.uk" wrote:
                Surely this sort of process is what nested conversations are made for ?


                Actually, no, they are more meant for things like master/detail views.

                • 5. Re: Nesting the Login Conversation
                  Tim Brewer Newbie

                  Thanks, Gavin, that approach is much more elegant than my fudge. I'll engineer that in.

                  However, I'm a stage down the login process and have hit another issue; If the user has bookmarked a page e.g.

                  http://seam.demo.jboss.com/main.seam

                  They can jump directly to this page without any login challenge. Admittedly they can't do much when they get there but it is a bit confusing.

                  I would rather they were forwarded to the login screen, but the @LoggedIn interceptor isn't fired & even if the interceptor was fired (e.g. via a factory or method call on the page) I wouldn't be able to specify an outcome for redirection.

                  I'm currently looking at the NavigationHandler to see if this will do the job. I'm new to JSF so I'm open to any better / alternative solutions.

                  Cheers,
                  Tim.

                  • 6. Re: Nesting the Login Conversation
                    Gavin King Master

                    Yes, this is because of the JSF lifecycle for non-faces requests (there is no action). I don't think you can solve this with a NavigationHandler - the NavigationHandler is only called to translate an action outcome to a viewid. When you hit main.seam directly, you already know the viewid.

                    I believe you *can* solve it with a PhaseListener, but you will need to do something like this:

                    UIViewRoot viewRoot = context.getApplication().getViewHandler()
                     .createView( context, "login.jsp" );
                    context.setViewRoot(viewRoot);


                    Or, perhaps, something like this:

                    String url = context.getApplication().getViewHandler().getActionURL( context, "login.jsp" );
                    url = encodeConversationId(url);
                    ExternalContext externalContext = context.getExternalContext();
                    externalContext.redirect( externalContext.encodeActionURL(url) );
                    context.responseComplete();


                    Note that I have not tried either thing.