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

Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.