Prevent p:messages component from showing messages which are already shown in p:message

别说谁变了你拦得住时间么 提交于 2019-12-05 18:30:20

Set redisplay attribute to false.

<p:messages ... redisplay="false" />

This way it won't redisplay messages which are already displayed before. One -obvious- requirement is that the <p:messages> component itself is placed after all those <h|p:message> components. If you actually need to position it visually before the <h|p:message> components, make use of CSS and perhaps JS to reposition it.

i used the following JS function oncomplete of blur event and it works fine:

function hideRequiredMessage(){
            var ErrorMessagesSpans= document.getElementById("myform:messages").getElementsByClassName("ui-messages-error-summary");
            if(ErrorMessagesSpans!=null && ErrorMessagesSpans.length > 0){
            var ErrorMessageSpan=ErrorMessagesSpans[0];
               if(ErrorMessageSpan.innerHTML==''){
                  //ErrorMessageSpan.className = '';
                   ErrorMessageSpan.parentNode.removeChild(ErrorMessageSpan);
              }
            }
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!