@ViewScoped Managed bean loads many times during postback

浪尽此生 提交于 2019-11-30 09:33:40

Look much like issue 1492. Here's a cite of relevance:

This is a chicken/egg issue with partial state saving. The view is executed to populate the view before delta state is applied, so we see the behavior you've described.

At this point, I don't see a clear way to resolve this use case.

The workaround, if you must use view-scoped bindings would be setting javax.faces.PARTIAL_STATE_SAVING to false.

Probably Primefaces is implicitly binding the uploaded file with the view and you need to add the following to the web.xml:

<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>

Give it a try and see if that helps. If it works, you may want to consider to turn if off for a specific view only. Globally turning off partial state saving will namely noticeably increase memory and/or bandwidth usage, depending on state saving method. Assuming that the view ID is /upload.xhtml, use this:

<context-param>
    <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
    <param-value>/upload.xhtml</param-value>
</context-param>

You can specify multiple view IDs by a semicolon.

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