Java Bean Scopes in JSF
By Ivan Lim Viewed: 31829 times Emailed: 236 times Printed: 284 times
scopes:
• None: Objects with this scope are not visible in any JSF page. When used in the configuration file, they indicate managed beans that are used by other managed beans in the application. Objects with none scope can use other objects with none scope.
• Request: Objects with this scope are visible from the start of the request until the end
of the request. Request scope starts at the beginning of a request and ends when the
response has been sent to the client. If the request is forwarded, the objects are visible
in the forwarded page, because that page is still part of the same request/response
cycle. Objects with request scope can use other objects with none, request, session,
or application scope.• Session: An object with session scope is visible for any request/response cycle that
belongs to a session. Objects with this scope have their state persisted between
requests and last until the object or the session is invalidated. Objects with session
scope can use other objects with none, session, or application scope.• Application: An object with application scope is visible in all request/response cycles
for all clients using the application, for as long as the application is active. Objects with
application scope can use other objects with none or application scope.
You may know that when you use the <useBean> standard action, you can specify similar scopes for the JavaBean. The difference is that JSP scope includes an additional scope named page. Because JSF requests often involve navigation between pages, objects with page scope have no value in a JSF application.
Most often, you will define your managed beans to have session scope. However, in some cases, you may have a managed bean that encapsulates global data. For example, you may have a managed bean that holds information common to every page in the application; in that case, you would define the managed bean to have application scope. Managed beans that you use only within a single request/response will have request scope.
Comments(1)
| 1. | thanks. that was fair enough. :) |
Latest Tutorials
| [2008-08-13] | Struts Vs JSF (A comparison of Struts against JSF) |
| [2007-10-06] | faces-config.xml to DirectTraffic in the JSF Application |
| [2007-10-06] | <convertNumber> and <convertDateTime> in JSF |
| [2007-10-06] | Action listeners in JSF |
| [2007-10-06] | Calling Multiple Listeners in JSF |
| [2007-09-19] | Using Javascript in JSF |
| [2007-09-19] | How to open a new browser window from my JSF page? |
| [2007-09-19] | Servlet error : java.lang.IndexOutOfBoundsException (JSF RI 1.1_01: IndexOutOfBoundsException) |
| [2007-09-19] | JSF - TreeNode.setID gets IllegalArgument Exception |
| [2007-09-18] | Install and Deploy JBoss Application Server |
| [2007-09-18] | What is JSF (JavaServer Faces)? |
| [2007-09-18] | Differences between JavaServer Faces technology and Struts |
| [2007-09-18] | JSF Basics |
| [2007-09-18] | The Relationship Between JSF and Other Java EE Technologies |
| [2007-09-18] | JSF Life Cycle |
Most Viewed Articles (in last 30 days)

