What does the view scope mean? Can anyone explain about it, so that I can understand how it differs from the request scope?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A
@ViewScopedbean lives exactly as long as a JSF view. It usually starts with a fresh new GET request, or with a navigation action, and will then live as long as the enduser submits any POST form in the view to an action method which returnsnullorvoid(and thus navigates back to the same view). Once you refresh the page, or return a non-nullstring (even an empty string!) navigation outcome, then the view scope will end.A
@RequestScopedbean lives exactly as long a HTTP request. It will thus be garbaged by end of every request and recreated on every new request, hereby losing all changed bean properties.A
@ViewScopedbean is thus particularly more useful in rich Ajax-enabled views which needs to remember the (changed) bean properties across Ajax requests. A@RequestScopedone would be recreated on every Ajax request and thus fail to remember all changed bean properties. Note that a@ViewScopedbean does not share any data among different browser tabs/windows in the same session like as a@SessionScopedbean. Every view has its own unique@ViewScopedbean.See also:
@ViewScoped