如何在重定向页面中显示人脸消息 [英] How to show faces message in the redirected page
问题描述
我提供了一个界面,允许用户为应用程序创建帐户.在流程结束时,注册方法执行注册流程,将成功消息添加到页面,然后将用户导航到显示所有系统用户的中央数据表.
I have provided an interface that allows users to create accounts for an application. At the end of the process the registration method performs the registration process adds a success message to the page and then navigates the user to a central data table that displays all the system users.
我遇到的问题是,由于页面重定向,成功消息永远不会显示.我不能在方法中使用 wait() ,因为在方法完成之前不会显示 JSF 消息.理想情况下,我希望显示成功消息,然后在指定时间后重定向页面.
The problem I have is that the success message never gets displayed because of the page redirect. I can't have a wait() in the method because the JSF message won't get displayed until the method has completed. Ideally I want the success message to be displayed and then a specified time later the page is redirected.
我怎样才能做到这一点?
How can I achieve this?
推荐答案
Keep the message in the flash scope. It'll survive the redirect.
context.addMessage(clientId, message);
externalContext.getFlash().setKeepMessages(true);
return "users.xhtml?faces-redirect=true";
<小时>
请注意,较旧的 Mojarra 版本具有一些与 Flash 范围相关的特殊错误:
Note that older Mojarra versions have some peculiar Flash scope related bugs:
- issue 1755 - Flash 范围内的消息比下一个请求的寿命更长 - 在 2.0.7/2.1 中修复.4
- issue 2130 - Flash cookie 启用数据攻击 - 已在 2.1.24/2.2.1 中修复一个>
- issue 2140 - 重定向到不同路径时 Flash cookie 不可用 - 已在 2.1.14/2.2 中修复.0
- issue 2906 - Flash cookie 为根目录下的应用程序使用错误的路径 - 已在 2.1.24/2.2 中修复.1
- issue 2959 - Flash 有时会创建 version1 cookie,但在 IE 中失败 - 已在 2.1.25/2.2 中修复.2
- issue 2977 - 会话过期后,Flash 导致旧 cookie 出现 NPE - 已在 2.1.25 中修复/2.2.2
- issue 2866 - Flash cookie 过期时未清除 - 已在 2.1.27/2.2.5 中修复
您最好至少升级到 Mojarra 2.1.27/2.2.5,以确保您的应用程序不受此影响.
You'd best to upgrade to a minimum of Mojarra 2.1.27 / 2.2.5 in order to ensure that your application is not affected by this.
这篇关于如何在重定向页面中显示人脸消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!