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

大城市里の小女人 提交于 2019-12-07 01:20:04

问题


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

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>

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

thank you


回答1:


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.

Thus, so

context.addMessage(null, message);

with

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

should do it for you.



来源:https://stackoverflow.com/questions/15598192/how-to-use-pgrowl-only-for-confirmation-not-validation-jsf2-primefaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!