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
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>
<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 are visible from the start the request until the end the request. Request starts at the beginning a request and ends when the response has been sent to the client. If the request is forwarded, the objects are visible the forwarded page, because that page is still part the same request/response cycle. Objects with request can use other objects with none, request, session,or application .
<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>
<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 is visible for any request/response cycle that belongs to a session. Objects with this have their state persisted between requests and last until the object or the session is invalidated. Objects with session can use other objects with none, session, or application .
<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>
<managed-bean-name>listvalue</managed-bean-name> <managed-bean-class>view.ListBean</managed-bean-class>
<managed-bean-scope>Session</managed-bean-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