问题
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