1 Reply Latest reply on Aug 22, 2011 6:04 PM by Darren Kramer

    Conversation Scope with AJAX question

    Darren Kramer Newbie

      I am writing a prototype application with JSF 2.0 and CDI and am wondering if there is an easy way to start my conversation during the initial rendering of the page (non faces request) instead of after the initial post.   For example:

      I have a registration page.  On this page is a User Name field.  On this field, I have a custom validator that checks the user name for uniqueness.  If the user name has already been take, I store the user name into a list of attempted user names and validation fails.  On the registration page, I have an ajax call on this field using the f:ajax tag.  Also on this page, I display at the bottom of the page a list of all user names the user has attempted that were already taken.  

      What happens is this:  If I navigate to the registration page and enter a user name that already exists, the AJAX call works, validation fails and I get the validation message and the attempted user name appears on the list.  However, the second time I enter a user name, I lose the first one.  It appears as if it is starting a new conversation (and yes, I did begin the conversation). 

      However, if I submit the form once (non-ajax), then everything works fine after that.  My conversation is started and persists across the ajax calls.

      So I know one solution would be to begin a conversation before navigating to this page, however, I was wondering if there is another easier way to do this?