咆哮的表面3.2

时间:2012-06-07 22:41:43

标签: jsf primefaces growl

我使用JSF 2.0和primefaces 3.2。我遇到了Growl的问题,当我点击按钮时,我看不到任何咆哮声。这是我的代码:

demarrageArretServices.xhtml

 <p:growl id="gr" showDetail="true" /> 
   <p:panel header="Etat du service Postfix" style="width:375px;height:200px;top:20px;left:20px;position:absolute;border-color:#66CCCC;border-style:solid;border-width:3px;">  
         <p:graphicImage value="/images/stop.png" style="top:4px;left:310px; position: absolute;width:30px;height:30px;"/>    
         <p:graphicImage value="/images/start.png" style="top:4px;left:340px; position: absolute;width:30px;height:30px;"/>
         <h:outputLabel value="Ce service est " style="top:70px;left:20px;position:absolute;font-size:17px;" />

         <p:commandLink id="ajax1" update="et1,bt1" actionListener="#{servicesBean.consulterEtatPostfix()}" style="top:70px;left:140px;position:absolute;font-size:17px;" >  
              <h:outputText value="actuellement" />  
         </p:commandLink>
         <h:outputText id="et1" value="#{servicesBean.etatPostfix}" style="font-style:italic;font-weight:bold;color:#66CCCC;top:68px;left:260px;position:absolute;font-size:19px;"/>

         <h:outputLabel value="Vous pouvez changer son état en cliquant" style="top:110px;left:20px;position:absolute;font-size:17px;" />
         <h:outputLabel value="sur" style="top:160px;left:20px;position:absolute;font-size:17px;" />

         <p:commandButton id="bt1" value="#{servicesBean.boutonPostfix}" actionListener="#{servicesBean.changerEtatPostfix()}" update="gr" style="top:150px;left:70px;position:absolute;font-size:16px;width:100px;height:35px;" />    

   </p:panel>



   <p:panel header="Etat du service Cyrus-Imap" style="width:375px;height:200px;top:170px;left:220px;position:absolute;border-color:#66CCCC;border-style:solid;border-width:3px;">
         <p:graphicImage value="/images/stop.png" style="top:4px;left:310px; position: absolute;width:30px;height:30px;"/>    
         <p:graphicImage value="/images/start.png" style="top:4px;left:340px; position: absolute;width:30px;height:30px;"/>
         <h:outputLabel value="Ce service est" style="top:70px;left:20px;position:absolute;font-size:17px;" />

          <p:commandLink id="ajax2" update="et2,bt2" actionListener="#{servicesBean.consulterEtatCyrus()}" style="top:70px;left:140px;position:absolute;font-size:17px;" >  
              <h:outputText value="actuellement" />  
         </p:commandLink>
         <h:outputText id="et2" value="#{servicesBean.etatCyrus}" style="font-style:italic;font-weight:bold;color:#66CCCC;top:68px;left:260px;position:absolute;font-size:19px;"/>


         <h:outputLabel value="Vous pouvez changer son état en cliquant" style="top:110px;left:20px;position:absolute;font-size:17px;" />
         <h:outputLabel value="sur" style="top:160px;left:20px;position:absolute;font-size:17px;" />

         <p:commandButton id="bt2" value="#{servicesBean.boutonCyrus}" actionListener="#{servicesBean.changerEtatCyrus()}" update="gr" style="top:150px;left:70px;position:absolute;font-size:16px;width:100px;height:35px;" />    


   </p:panel>
        </h:form>

ServicesBean.java

import javax.faces.application.FacesMessage;  
import javax.faces.context.FacesContext;
public void changerEtatPostfix ()
    {

        if (boutonPostfix.equals("arrêter"))
        {
            executerCommande ("rcpostfix stop");
            FacesMessage msg = new FacesMessage("Succès", "Postfix est arrêté ");    
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }
        else
        {   
            executerCommande ("rcpostfix start");
            FacesMessage msg = new FacesMessage("Succès", "Postfix est démarré");    
            FacesContext.getCurrentInstance().addMessage(null, msg );
        }
    }
public void changerEtatCyrus ()
    {

        if (boutonCyrus.equals("arrêter"))
        {
            executerCommande ("rccyrus stop");
            FacesMessage msg = new FacesMessage("Succès", "Cyrus-IMAP est arrêté ");    
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }

        else
        {
            executerCommande ("rccyrus start");
            FacesMessage msg = new FacesMessage("Succès", "Cyrus-IMAP est démarré");    
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }
    }}  

2 个答案:

答案 0 :(得分:0)

确保您在表格标签内

<h:form id="form">
    <p:growl id="gr" showDetail="true" /> 

...

</h:form>

答案 1 :(得分:0)

您需要从命令按钮更新growl组件,或者您可以使用在每个ajax请求/响应后更新autoUpdate=true的{​​{1}}属性:

p:growl