2013-03-24 58 views
6

Tôi muốn sử dụng p:growl chỉ khi hộp thoại được đệ trình để xác nhận người dùng rằng hồ sơ được lưu và tôi sử dụng p:message để xác nhậnlàm thế nào để sử dụng p: tiếng gầm vang lên chỉ để xác nhận không xác nhận jsf2 primefaces

nhưng vấn đề là p: tiếng gầm cũng được sử dụng để xác nhận bên cạnh 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> 

thế nào để cho các p: tiếng gầm chỉ cho các hồ sơ được lưu để xác nhận nó, nhưng không xác nhận vì giá trị của tiếng gầm được thiết lập từ bean được quản lý:

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

Tôi hy vọng tôi đã giải thích nhiều vấn đề của tôi

cảm ơn bạn

Trả lời

10

Nếu bạn đặt thông điệp với một ID null khách hàng, sau đó nó sẽ trở thành một "thông điệp toàn cầu". Bây giờ, nếu bạn đặt thuộc tính globalOnly="true" trong <p:growl>, thì nó sẽ hiển thị chỉ loại thư đó.

Do đó, vì vậy

context.addMessage(null, message); 

với

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

nên làm điều đó cho bạn.

+0

cảm ơn bạn, đây chính xác là mục tiêu của tôi –

+0

Bạn được chào đón. – BalusC