可以在JSF 2配置文件中将Flash.keepMessage设置为true吗? [英] set Flash.keepMessage to true in JSF 2 configuration file is possible?

查看:174
本文介绍了可以在JSF 2配置文件中将Flash.keepMessage设置为true吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此行:

FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);

可以在任何配置文件中通过其他代码更改吗?每当我需要从该行的代码重定向时,我都希望避免键入此行:

Can be changed by another code in any configuration files? I want to avoid typing this line whenever I need to redirect from code whit this line:

     FacesContext.getCurrentInstance().getExternalContext().redirect("errorApp");

致谢.

推荐答案

没有配置设置可以更改保留消息"功能.

There is no configuration setting to change the "keep messages" feature.

只需创建一个实用程序方法即可通过单个方法调用替换重复的代码.例如

Just create an utility method which replaces the repeated code by a single method call. E.g.

public static void addGlobalInfoFlashMessage(String message) {
    FacesContext context = FacesContext.getCurrentInstance();
    context.getExternalContext().getFlash().setKeepMessages(true);
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, message, null));
}

这篇关于可以在JSF 2配置文件中将Flash.keepMessage设置为true吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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