3 Replies Latest reply on Apr 16, 2008 6:30 PM by andygibson.contact.andygibson.net

    Best Practices in New User Registration

      If you have a session-scope User class with all properties set to required, how would you code a registration function to register new Users?

      One way I see is to inject a new conversation-scoped User object for the duration of the registration process - but assume that it's a multi-page registration process (the idea being that by the end of the registration process, all fields which were required have now been filled in).

      After the first page which gathers some initial data (e.g. name, address) completes, wouldn't the required properties on the User object complain before we can get to the second/third/etc page, which gathers the remaining information?

      What can you suggest apart from duplicating the User object into a TemporaryUser object that's identical but doesn't have all properties as required?


        • 1. Re: Best Practices in New User Registration

          You could try to validate the fields you'd like on every single page (s:validate per input rather than s:validateAll on form). Then, after the last page, persist the user. Propagate the conversation over the pages in the registration process.

          • 2. Re: Best Practices in New User Registration

            Oh, I think I may have misinterpreted how validation works.

            The documentation says it validates a JSF input field against the bound property using Hibernate Validator - but when does this happen?

            Does validation occur everytime a submit occurs on that form field, or only when the entity is persisted?

            Also, if I understand correctly - defining validator annotations on the entity's properties alone does nothing - ONLY when s:validate or s:validateAll is associated with an input that's associated with that property does validation occur?

            • 3. Re: Best Practices in New User Registration

              I think you should be OK since the validation occurs on a per page basis, so if you have fields 1-5 on one page and fields 6-10 on another page, the only validation that will take place on the first page is fields 1-5 so you don't have to worry about fields 6-10 being blank until you try submitting the second page.

              Just make sure that you have the flush mode set to manual so it doesn't try to persist the user when you go from page 1 to page 2 since that will raise errors if the not null constraints are also present in the database.