Destroying view-scoped beans when session ends

Deadly 提交于 2019-12-03 20:10:31

Create a @SessionScoped bean to hold the resources (in some collection/array?) and inject it in the @ViewScoped bean and then rely on the @PreDestroy of the session scoped bean.

True, this way the resources live a little longer than you want, but that's the most easy and reliable solution you can get. If you want to keep the @PreDestroy in the view scoped bean, then you'd need to somehow make sure that the enduser always performs navigation by a HTTP POST request on exactly this view scoped bean. You can't reliably guarantee that (the enduser's PC might crash and so on).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!