1.2.2. How it works
When the form is submitted, JSF asks Seam to resolve the variable named user.
Since there is no value already bound to that name (in any Seam context), Seam
instantiates the user component, and returns the resulting User entity bean
instance to JSF after storing it in the Seam session context.
The form input values are now validated against the Hibernate Validator
constraints specified on the User entity. If the constraints are violated, JSF
redisplays the page. Otherwise, JSF binds the form input values to properties
of the User entity bean.
Next, JSF asks Seam to resolve the variable named register. Seam finds the RegisterAction
stateless session bean in the stateless context and returns it. JSF invokes
the register() action listener method.
Seam intercepts the method call and injects the User entity from the Seam
session context, before continuing the invocation.
The register() method checks if a user with the entered username already exists. If
so, an error message is queued with the FacesMessages component, and a null outcome is
returned, causing a page redisplay. The FacesMessages component interpolates the JSF
expression embedded in the message string and adds a JSF FacesMessage to the view.
If no user with that username exists, the "/registered.xhtml" outcome triggers a browser
redirect to the registered.xhtml page. When JSF comes to render the page, it asks Seam to
resolve the variable named user and uses property values of the returned User
entity from Seam's session scope.
|