Primefaces:Ajax状态在重定向到新页面时停止

问题描述:

我有 page1.jsf page2.jsf . Page1的<p:ajaxstatus/>中带有自定义微调框. 在页面1上执行操作并将用户重定向到页面2时,微调器立即启动和停止,但page1保持原样,几秒钟后加载并渲染了page2.

I have page1.jsf and page2.jsf. Page1 has <p:ajaxstatus/> with custom spinner in it . When an action is performed on page 1 and the user is redirected to page 2, the spinner starts and stops immediately but page1 remains as it is and after few seconds page2 is loaded and is rendered.

如何使微调框旋转,直到完全渲染page2.

How can I keep the spinner spinning until page2 is fully rendered.

我假设您正在为页面1使用@ViewScoped bean.

I assume you are using a @ViewScoped bean for page1.

当您重定向到page2时,视图将创建到page2,并且已取消引用/销毁了page1的视图作用域bean.因此,对该bean的Ajax请求将被忽略.

When you redirect to page2, the view is created to page2, and the view scoped bean for page1 is dereferenced/destroyed. Ajax request to that bean are thus ignored.

我知道的唯一解决方案是将page1的bean设置为@SessionScoped,但这可能会影响应用程序的行为.

The only solution that I know of would be setting the bean for page1 as @SessionScoped, but that may affect the behavior of your application.