如何仅使用p:growl进行确认而不验证jsf2 primefaces [英] how to use p:growl only for confirmation not validation jsf2 primefaces

查看:144
本文介绍了如何仅使用p:growl进行确认而不验证jsf2 primefaces的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅当提交对话框以确认用户已保存记录并且我使用p:message进行验证

I want to use p:growl only when the dialog is submited to confirm user that the record is saved and I use the p:message for validation

但是问题是p:growl也用于p:message

but the problem is the p:growl is used also for validation beside the p:message

<p:dialog id="dialog" modal="true" header="Nouveau Type"
                widgetVar="dlg">

                <h:panelGrid id="panel" columns="3" cellpadding="5">



                    <h:outputLabel for="libelle" value="Libelle :" />
                    <p:inputText value="#{typeMB.newtype.libelle}" id="libelle"
                        required="true" label="libelle" requiredMessage="Veuillez saisir une valeur" 
                        validatorMessage="la valeur doit depasser 2 caracteres" >
                        <f:validateLength minimum="2"  />
                    </p:inputText>
                    <p:message for="libelle" display="text"  />

                    <h:outputLabel for="commission" value="commission :" />
                    <h:inputText value="#{typeMB.newtype.commission}" id="commission"
                        required="true" label="commission" 
                        requiredMessage="Veuillez saisir une valeur" 
                        converterMessage="Veuillez saisir un nombre"
                        validatorMessage="Veuillez saisir entre 0 et 100" >
                        <f:validateDoubleRange minimum="10" maximum="100" />
                        </h:inputText>
                    <p:message for="commission" display="text" />


                    <f:facet name="footer">
                        <p:commandButton id="ajouterBoutton" value="Ajouter"
                            update="panel :form:ourdatatable" actionListener="#{typeMB.ajouter}"
                            oncomplete="handleLoginRequest(xhr, status, args)" />
                        <p:commandButton type="reset" value="vider" update="panel"
                    process="@this" actionListener="#{typeMB.reset}" />
                    </f:facet>

                    <p:growl style="z-index=1000" id="growl" showDetail="true"
                        life="3000" />
                </h:panelGrid>


            </p:dialog>

保存了只让记录使用p:growl进行确认的方法,但没有进行验证,因为咆哮的值是从托管bean设置的:

how to let the p:growl only for the record is saved to confirm it but not validation because the value of the growl is set from managed bean :

msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Confirmation",
                "Type ajouté avec succés");

我希望我能解释更多我的问题

I hope I explained more my problem

谢谢

推荐答案

如果使用null客户端ID设置消息,则该消息将成为全局消息".现在,如果您在<p:growl>中设置了globalOnly="true"属性,那么它将仅显示 这样的消息.

If you set the message with a null client ID, then it becomes a "global message". Now, if you set globalOnly="true" attribute in <p:growl>, then it will display only that kind of messages.

因此,

context.addMessage(null, message);

使用

<p:growl ... globalOnly="true" />

应该为你做.

这篇关于如何仅使用p:growl进行确认而不验证jsf2 primefaces的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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