Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am quite confused with the view scope. I thought it could survive a JSF navigation to another page (no redirect, obviously), but it doesn't. So what's the advantage to use it instead of request scope, that if i summoned the same view it will be the same object?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
666 views
Welcome To Ask or Share your Answers For Others

1 Answer

The advantage is that the bean survives postbacks to the same view. You don't need to preserve any data yourself anymore when used in rendered attributes or as model for h:dataTable or as hidden inputs, etcetera. In the past, a lot of hacks were been used to go around this.

A view scoped bean lives as long as you interact with the same view (i.e. you return void or null in bean action method). When you navigate away to another view, e.g. by clicking a link or by returning a different action outcome, then the view scoped bean will be trashed by end of render response and not be available in the next request.

See also:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...