users@javaserverfaces.java.net

Re: Which phase in the Lifecycle is a managed bean's constructor accessed?

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Wed, 30 May 2007 12:52:34 -0700

Todd Patrick wrote:
> Which Phase in the Lifecycle is a managed bean's constructor accessed?
>
> In the Standard lifecycle, I believe it is 1, RESTORE_VIEW.
>
> There is no mention of the managed bean's constructor at:
>
> http://java.sun.com/javaee/5/docs/tutorial/doc/JSFIntro8.html#wp123500
>
> Thanks,
>
> --Todd
> NOTICE: This email message is for the sole use of the intended
> recipient(s) and may contain confidential and privileged information.
> Any unauthorized use, disclosure or distribution is prohibited. If you
> are not the intended recipient, please contact the sender by reply
> email and destroy all copies of the original message.
It depends on when the bean is first accessed with relation to its scope.

Say you have a request scoped bean bound to the rendered attribute of
a component. The first time the view is accessed, the bean would be
created during RENDER_RESPONSE. On a post back, the same
bean would be created during APPLY_REQUEST_VALUES.

If the bean was session scoped, the constructor would most likely
only have been invoked the first time the view was rendered for that
user.