When is a managed bean constructor called?
Asked Answered
C

1

6

When is a managed Bean constructor called? Is it called only once?

Thank you!

Capstan answered 20/12, 2013 at 14:4 Comment(0)
L
6

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?

Lissettelissi answered 20/12, 2013 at 14:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.