View not destroyed when closing browser tab on page backed by omnifaces @ViewScoped #208
I set the view/logical view limits to 3 and deployed a simple JSF page with omnifaces ViewScoped backing bean. Closing tabs does not appear to do anything. I would have expected the secondary beans to have been destroyed so that the first bean is never automatically expired.
I'm using GF 4.1, JSF 2.2, Omnifaces 2.2
Steps to reproduce:
javax.faces.application.ViewExpiredException: viewId:/viewBean.jsf - View /viewBean.jsf could not be restored.
The text was updated successfully, but these errors were encountered:
Unfortunately neither Mojarra nor MyFaces would clean up server side view state on this, but this is at least a start.
Reproduced. Nice find. Unfortunately, neither Mojarra nor MyFaces keeps server side view state "in sync" with PreDestroyViewMapEvent, so those server side view states still stick around. Your best bet is using client side state saving instead.
Theoretically, we could solve this by providing our own server side state manager, but this is not a trivial task. I'd rather first look how the JSF API itself can be improved with regard to this.
JSF own view scoped beans (javax.faces.bean/view.ViewScoped) associated with the view (only if the view has an OmniFaces CDI view scoped of course). Also, any component event listeners on UIViewRoot will be restored and those listening on PreDestroyViewMapEvent will be invoked.
(MyFaces autogenerated an ID which wasn't re-generated in postback, causing corrupted view state during unload)
(though using @ViewScoped beans in stateless JSF doesn't make sense)