如何在重定向页面中显示人脸消息 [英] How to show faces message in the redirected page

查看:25
本文介绍了如何在重定向页面中显示人脸消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供了一个界面,允许用户为应用程序创建帐户.在流程结束时,注册方法执行注册流程,将成功消息添加到页面,然后将用户导航到显示所有系统用户的中央数据表.

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:

您最好至少升级到 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆