- Mastering JavaServer Faces 2.2
- Anghel Leonard
- 93字
- 2021-12-08 12:41:32
Managed bean instantiation
By default, a managed bean is instantiated at first reference to it (a request, for example)—this is known as lazy instantiation. You can alter the default behavior by adding the eager
attribute and set its value to true
. This will instantiate the managed bean when the application starts, before any request is made. But, it is important to know that this works only for application scoped beans and the eager instantiated bean is placed in the application scope, as shown in the following lines of code:
@ManagedBean(eager=true) @ApplicationScoped