Tuesday, September 28, 2010

Jsf Scope


Scope: scope is way to implementing the encapsulation .it is process to limiting the access of the object .
JSF have four type of the scope
1-None
2-Request
3-Session
4-Application
1-Nope :object with this scope are not visible in any jsf pages. they are not used direct .they are used by the other managed bean and there scope automatic same as the manage bean .when in the configuration file,they indicate managed beans that are used by other managed beans in the application .
Example:

<managed-bean>
    <managed-bean-name>helperbeam</managed-bean-name>
    <managed-bean-class>view.BeanClassForJsp</managed-bean-class>
    <managed-bean-scope>none</managed-bean-scope>
  </managed-bean>
2- 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.
 

<managed-bean>
<managed-bean-name>listvalue</managed-bean-name>
    <managed-bean-class>view.ListBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
3- 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.
<managed-bean>
    <managed-bean-name>listvalue</managed-bean-name>    <managed-bean-class>view.ListBean</managed-bean-class>
    <managed-bean-scope>Session</managed-bean-scope>
  </managed-bean>

 4-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.
<managed-bean>
    <managed-bean-name>listvalue</managed-bean-name>
    <managed-bean-class>view.ListBean</managed-bean-class>
    <managed-bean-scope>Application</managed-bean-scope>
  </managed-bean>

No comments:

Post a Comment