When is a managed Bean constructor called? Is it called only once?
Thank you!
When is a managed Bean constructor called? Is it called only once?
Thank you!
A managed bean constructor invocation is performed by the JSF Lifecycle Process. It depends which scope is declared for the bean. If the scope of the Managed Bean is "request" than JSF provides one bean instance for each request. After the request has finished the state of the bean is undefined.
Another scope is the session scope which means that one bean instance is provided for the complete web session. So you are responsible for managing a correct bean state for the whole session.
There exist some other scopes have a look at JSF Lifecycle and Scopes of ManagedBeans.
Additionally hava a look at the FacesContext and FacesServlet: Nice description is here: Lifecycle of FacesContext?
© 2022 - 2024 — McMap. All rights reserved.