JSF 消息持久化 [英] JSF messages persistance

查看:23
本文介绍了JSF 消息持久化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 viewScoped bean,它有一些业务逻辑验证.我使用

将此验证的结果错误显示到页面

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, result, null));

问题是:

  1. 用户提交无效表单
  2. 重新显示表单,由于使用 PRG 而未向用户显示消息

我使用以下代码行解决了这个问题:

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

现在的问题是业务逻辑验证消息持续时间太长:

  1. 用户提交无效表单
  2. 重新显示错误消息的表单
  3. 用户更正并提交有效表单
  4. 表单重新显示成功"消息,但也显示以前的错误消息.

我该如何解决这个问题?

解决方案

根据您的问题评论,您使用的是 Mojarra 2.0.3:

<块引用>

[JSFImplManagementDeployer] 初始化了 3 个 JSF 配置:[Mojarra-1.2, MyFaces-2.0, Mojarra-2.0][javax.enterprise.resource.webcontainer.jsf.config] 初始化 Mojarra 2.0.3 (b05)

这真的是一个古老的 Mojarra 版本.它目前已经超过 3.5 岁了!(2010 年 7 月发布).您的具体问题是由 issue 1751 引起的,该问题已在 2.0.7/2.1 中修复.4.然而,之后还有许多其他与闪存范围相关的问题报告.Flash Scope 位于较旧的 Mojarra 版本中,存在以下主要问题:

总而言之,可以得出结论,您需要至少升级到 Mojarra 2.1.27/2.2.5 才能摆脱所有这些问题.

记录器中的 JSFImplManagementDeployer 条目可识别为 JBoss 6.x 中的条目.古老的 Mojarra 2.0.3 反过来表明您仍在使用第一个 JBoss 6.0.0 版本.这充满了错误,强烈建议升级到更新的 JBoss 服务器,不仅可以修复那些 Mojarra 问题,还可以修复许多其他问题.考虑升级到 JBoss AS 7.3.x 或 EAP 6.2.x.如有必要,您可以根据此答案中的说明升级其捆绑的 Mojarra:在 JBoss AS/EAP/WildFly 中升级 JSF/Mojarra.

I have a viewScoped bean which has some business logic validation. I display the resultant errors from this validation to the page using

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, result, null));

The problem is:

  1. user submits invalid form
  2. form redisplayed, messages not displayed to user due to using PRG

I solved this using the following line of code:

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

Now the problem is that the business logic validation messages persist too long:

  1. user submits invalid form
  2. form redisplayed with error messages
  3. user corrects and submits valid form
  4. form redisplayed with "success" message, but also previous error messages also displayed.

How can I fix this?

解决方案

Based on your question comment, you're using Mojarra 2.0.3:

[JSFImplManagementDeployer] Initialized 3 JSF configurations: [Mojarra-1.2, MyFaces-2.0, Mojarra-2.0]
[javax.enterprise.resource.webcontainer.jsf.config] Initializing Mojarra 2.0.3 ( b05)

This is really an ancient Mojarra version. It's currently over 3.5 years old already! (released July 2010). Your concrete problem is caused by specifically issue 1751 which is fixed in 2.0.7/2.1.4. There have however been many other issue reports related to the flash scope afterwards. The flash scope is in older Mojarra versions known for the following major problems:

All in all, concluded can be that you'd need to upgrade to a minimum of Mojarra 2.1.27 / 2.2.5 in order to get rid of all those problems.

The JSFImplManagementDeployer entry in the logger is recognizable as the one from JBoss 6.x. The ancient Mojarra 2.0.3 in turn suggests that you're still using the very first JBoss 6.0.0 release. This is so full of bugs and it's strongly recommended to upgrade to a more recent JBoss server, not only to fix those Mojarra issues, but also many others. Consider upgrading to JBoss AS 7.3.x or EAP 6.2.x. If necessary, you can upgrade its bundled Mojarra based on the instructions in this answer: Upgrade JSF / Mojarra in JBoss AS / EAP / WildFly.

这篇关于JSF 消息持久化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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