2 Replies Latest reply on Dec 22, 2009 1:27 AM by Ian R

    Understanding Conversation scope and how it works

    Ian R Newbie
      Hi, just wanting to clarify my understanding of Conversation scope and what it can do for me. I have an example JSF2 application fragment which I'll use as follows:

      I have a login prompt on a welcome screen. I have no validation on the fields there. The action calls a method on a bean, which is ConversationScoped. If the login fails (usually because the username is invalid), I want to redirect the user to another (login) screen where the username is validated (using BeanValidation), and take the username they entered onto the new screen.

      I have a separate method for logging in from the welcome screen. When it fails there, I make the conversation non-transient. I then copy the username into a new field, which is displayed on the new screen. I then redirect to the new screen using a format like "login?faces-redirect=true&cid=<conversion ID>".

      Given I have made the conversation non-transient and am supplying the conversation ID to the new URL, I would think I should be getting the same bean back when I call a method on that bean. But this isn't the case - I seem to be getting a new bean, which is exactly what I am trying to avoid.

      Am I missing something obvious here, or don't I understand the conversation scope properly?