开发者

JSF 2 - Where does a @ViewScoped bean live between requests?

I'm trying to better understand the low-level workings of a @ViewScop开发者_运维百科ed bean in JSF 2. Where does the server keep the view-scoped bean between requests? I've noticed that my view-scoped beans need to implement Serializable, so they must get serialized to some location.

Can anyone explain this or provide a link to documentation that explains it?

I'm asking the question because I may have introduced a scope-related defect into my webapp. Understanding how @ViewScoped works will help me rule out some of the potential causes.


@ViewScoped beans are stored in the viewMap of the UIViewRoot:

UIViewRoot is the UIComponent that represents the root of the UIComponent tree. This component renders markup as the response to Ajax requests. It also serves as the root of the component tree...

In fact, you can access this viewMap yourself, and stuff values in there using:

facesContext.getViewRoot().getViewMap()...

For more information, see the JSF API doc: http://javaserverfaces.java.net/nonav/docs/2.0/javadocs/javax/faces/component/UIViewRoot.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜