为什么面对组件上的消息是附加的?

时间:2013-03-18 17:41:26

标签: jsf

我正在向我的组件添加验证消息。我有许多输入,然后我在一个附加到隐藏输入的验证器中验证它们,隐藏输入在所有这些组件之上声明。我发现每次验证失败时,相同的消息都会不断添加。

输入x大于输入Y ”之类的消息显示两次,即使它应该出现一次。然后我纠正错误值,它就消失了。接下来我故意再次插入相同的错误值。然后我会看到上面的错误消息三次次。

如何清除先前请求中的消息?

这是人为的相关代码:

if (all condition passes) {
    for(UIInput:components){
        input.setValid(true);
    }


} else {
      //Find out the first component that fails the validation and mark it red
      FacesContext context = FacesContext.getCurrentInstance();
      UIInput input= components.getInvalidComponent();
      input.setValid(false);
      context.addMessage(input.getClientId(context),message) ;                           
    }

P.S:我正在使用JSF1.2

0 个答案:

没有答案