Managed Bean scopes in JSF 2.0

Posted on Updated on


Managed beans as the name speaks, acts as the model for the JSF UI. Their life cycle is governed as per JSF specification.


Though the life time is governed by the scope in which a given managed bean is added.

Scope Annotation Description
none @NoneScoped A bean in none scope will not be instantiated unless another managed bean calls for it.
They are created on demand, and are not stored in any other scope. Instance created will
remain untill the caller managed bean exists.
request @RequestScoped A bean in request scope will be instantiated per HTTP request, there life time is untill
response is sent back.
view @ViewedScope A bean in view scope will be available till the time user is on the same view, navigating to
other view will result in deallocation of the managed bean.
session @SessionScoped A bean will be available till the session is invalidated. This scope is good if you want to
manage data which is required for the complete session of the user.
applcation @ApplicationScoped A bean marked with this scope will be available to all the users, untill application is available.
custom @CustomScoped If the content of <managed-bean-scope> or value attribute of @CustomScoped evaluates to class which implements java.util.Map then the JSF runtime will use the map as the scope for the managed bean.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s