防止p:messages组件显示已经在p:message中显示的消息 [英] Prevent p:messages component from showing messages which are already shown in p:message

查看:137
本文介绍了防止p:messages组件显示已经在p:message中显示的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入组件,该组件具有三种验证类型(required,validatorMessage,converterMessage),并且此输入具有自己的消息图标,并且整个表单具有消息组件,以显示所有组件的所有消息,如下所示:

i have an input component that has three types of validation (required,validatorMessage,converterMessage) and this input has its own message icon, and the whole form has a messages component to display all the messages for all components as follows:

<p:message for="idEstNumOfUser" display="icon" id="msgEstNumOfUser" />
                    <p:inputText id="idEstNumOfUser"
                            placeholder="Estimated Number of Users"
                            value="#{mybean.estimatedUserCount}" required="true" requiredMessage=""
                            maxlength="8" title="Estimated Number of Users"
                            validatorMessage="Please enter digits only for 'Estimated Number of Users'"
                            converterMessage="Please enter digits only for 'Estimated Number of Users'">
                            <f:convertNumber />
                    <p:ajax event="blur" update=":betasignup:msgEstNumOfUser" />
                    </p:inputText>

                    <p:messages id="messages"  autoUpdate="true"/>

在错误消息之前,我有一种样式,显示警告图标,如下所示:

and i have a style before the error message that shows a warning icon as follows:

.ui-messages-error-summary:before{
                       font-family: FontAwesome;
                       speak: none;
                       font-style: normal;
                       font-weight: normal;
                       font-variant: normal;
                       text-transform: none;
                       line-height: 1;
                       -webkit-font-smoothing: antialiased;
                       content: "\f05a";
                       margin-right: 6px;
                    }

发生了什么:在发生需要验证的情况下,生成的用于邮件的html组件是:

WHAT IS HAPPENING: the generated html for messages component in the case required validation occurs is:

              <div class="ui-messages-error ui-corner-all">
              <span class="ui-messages-error-icon">
              </span>
              <ul>
               <li>
                 <span class="ui-messages-error-summary">
                 </span>
              </li>
             </ul>
            </div>  

因此,将应用 .ui-messages-error-summary:before 的样式,并且我不希望在进行必要的验证时应用该样式.

so the style for .ui-messages-error-summary:before is applied, and i don't want it to be applied when required validation occurs.

在这种情况下,如果有任何建议可以使验证更好,请提出建议.

if there are any suggestions to make validation better in this case, please advise.

推荐答案

redisplay属性设置为false.

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

这样,它不会重新显示以前已经显示过的消息.一个明显的要求是,将<p:messages>组件本身放置在所有<h|p:message>组件之后之后.如果您实际上需要在视觉上将其放置在<h|p:message>组件之前,请使用CSS或JS重新放置它.

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.

这篇关于防止p:messages组件显示已经在p:message中显示的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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