validation - 如何使用 p :growl only for confirmation not validation jsf2 primefaces

标签 validation jsf-2 primefaces message growl

我想用p:growl仅当提交对话框以确认用户已保存记录并且我使用 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>

如何让 p:growl 仅用于记录被保存以确认它而不是验证,因为 Growl 的值是从托管 bean 设置的:
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Confirmation",
                "Type ajouté avec succés");

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

谢谢你

最佳答案

如果您使用 null 设置消息客户端 ID,那么它就变成了“全局消息”。现在,如果你设置 globalOnly="true" <p:growl> 中的属性,那么它将只显示那种消息。

因此,所以

context.addMessage(null, message);


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

应该为你做。

关于validation - 如何使用 p :growl only for confirmation not validation jsf2 primefaces,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15598192/

相关文章:

java.lang.IllegalStateException - 提交响应后无法创建 session

jsf - 命令按钮在第二次按下时调用操作 (jsf)

javascript - 如何验证电子邮件地址与网站域名是否匹配?

jsf - JSF返回带有纯/原始XHTML/XML/EL源的空白/未分析页面,而不是呈现的HTML输出

javascript - 提交表单时验证所有 html 行

ajax - p :ajax on p:inputText 未调用监听器

jquery - 如何从 bean 跳转到 Primefaces 数据表到最后一页?

javascript - 获取动态生成的 id 元素的内部文本以发送到 Google Analytics

validation - Symfony 表单验证约束表达式

javascript - jquery验证后的ajax请求