When client state preservation is enabled, and we use a ViewScoped bean, is the ViewScoped bean session serialized to the page or is it said to be stored in the session with a token / key that is serialized on the page?
Mojarra 2.x stores a beans scope view in an HTTP session. There is an undocumented setting in which by default no more than 25 views with beans coverage. See also issue 4015 . In other words, physical view bean instances are never stored in the JSF view state. They are referenced only by the UUID, which, in turn, is stored in the JSF view state. Thus, they are not serialized in the JSF view state, regardless of how the client / server state is maintained.
It may happen here that if it is serialized, then we might want to not worry about not storing large instance variables on the ViewScoped bean, since it is serialized on the page and goes back / forward along the wire.
This is an urgent problem. Even this was true, but we are talking about rather extreme cases. A collection of 100 medium objects with every 10 average properties should already be no more than ~ 5 KB in size of the view state. Note that you can get more bandwidth by enabling gzip compression on a web server, even up to 70% on a text resource.
If you're dealing with big data, the size of the HTTP session storage can in turn be a problem. See Also JSF 2.2 Memory Consumption: Why does Mojarra store ViewScoped beans from the last 25 views in memory? Ideally, the scope of the bean should simply be destroyed as soon as the page to which it refers is unloaded using the GET navigation or the browser tab. The default view of the JSF bean does not do this. It is only destroyed during the postback to another view or when the session expires.
If you are using the JSF OmniFaces Utility Library starting from version 2.2 @org.omnifaces.cdi.ViewScoped supports destruction during unloading. This should positively affect the size of the HTTP session storage.
Balusc
source share