简体   繁体   English

如何使用p:growl仅用于确认而不是验证jsf2 primefaces

[英]how to use p:growl only for confirmation not validation jsf2 primefaces

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:growl还用于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>

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 : 如何让p:growl仅为记录保存以确认它但不验证,因为growl的值是从托管bean设置的:

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

I hope I explained more my problem 我希望我能解释更多我的问题

thank you 谢谢

If you set the message with a null client ID, then it becomes a "global message". 如果使用null客户端ID设置消息,则它将成为“全局消息”。 Now, if you set globalOnly="true" attribute in <p:growl> , then it will display only that kind of messages. 现在,如果在<p:growl>设置globalOnly="true"属性,那么它将显示那种消息。

Thus, so 因此,如此

context.addMessage(null, message);

with

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

should do it for you. 应该为你做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM