2017  Kodetalk | Feedback | Privacy Policy | Terms | About

what are different scopes of managed bean and how to use them in jsf

what are different scopes of managed bean and how to use them in jsf
What is a managed bean?

A managed bean (sometimes simply referrred to as an MBean) is a Java object that matches the JavaBean specification. The bean is automatically created, and has a lifetime that depends on the scope it has.

What are the differenct scopes?

  • none means the bean only exists within the function it is called. It is like a local variable, but one which you don¬ít have to declare.
  • request scope allows a bean to exist during the lifecycle of a page refresh
  • a bean with a view scope exists as long as the XPage is not reloaded
  • flash scope is not a valid option out of the box, but can be implemented via an extension. See here. This allows you to use a bean to pass values between one XPage and another
  • a managed bean with a session scope exists as long as the user works with the application, and any other XPages, in that database. The bean ends when the user closes the browser, or session expires
  • a bean with application scope can be accessed by any user of the database application. The data is not private. The bean lasts for as long as the application or database is being used, and for up to 30 minutes afterwards
  • there is no server scope which would work across databases, as such. There are, however, implementations of this.

How to use them in JSF?

 Have a look into http://www.java2s.com/Tutorials/Java/JSF/0060__JSF_Managed_Beans.htm for more details of use manged bean scope in JSF.

Answer is