@ViewScoped creating new instance on every postback

眉间皱痕 提交于 2019-12-06 12:36:31
BalusC

A view scoped JSF managed bean should normally not be recreated on postbacks at all.

This will however happen in specific circumstances, all related to the chicken-egg issue as described in Mojarra issue 1492 (which is fixed for the upcoming Mojarra 2.2 by the way). A view scoped bean will be recreated when you're binding attributes of tag handlers like JSTL <c:forEach> to a property of the view scoped bean, or when you're using JSF component binding to a property of the view scoped bean. The solution would be to use JSF components instead of JSTL tags and to avoid using binding on a bean of a broader scope than the request scope.

See also

What is a bean scope of fileDAO?

It would be better to get spring inject that dependency without getting application context from servlet one and then retrieving bean from it.

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