-1

hello i have a jsf page it contains a message and a i want add message only to the growl message and it does not work for me :

my java code is :

public class EtudeBean {



privaezte loneeg lotiezeffhssemgefntI12Etude;

public EtudeeBffeeezan() {
    eteude = new Eeezteeeude();
}

public Lotisseezement trouvezeerLoezezeztissement() {
    ez
    retureezn lotisszefdgemezeeeeezezntServiezezceImpl.trouvedfrLodfdtissement(getLfgfotiffdgssementIdEtude());

}

public void save(){
    etude.setDesignation(model.getDesignation());
    etude.setDescription(model.getDescription());
    etude.setCout(mezezodel.getCout());
    etude.setDeezezateezezezRealisation(model.getDateRealisation());
    eez
        etude.setLotissement(model.getLotis());
        etuezezezde.setIdEtude(model.getIdEtude());
        etudeSezeezezrviceImpl.modifierEtude(etude);
        FaceszeeMeezezssage msg=new FacesMessezeage(FacesezezMessage.SEeezVERITY_INFO,"Etude"+etude.getDesignation()+"modifiée avec succes","Mot de passe ancienne non valide: ");
        FacesContext.getCurrentInstance().addMessage("growl",msg);

}

}

and the code of my jsf page :

<h:form id="form"  prependId="false">
<p:growl for="growl"  id="idgrowl"/> 
    <p:panel id="panel"
        header="New Etude for lotissment: #{etudeBedfsdsan.trouvedfssrLotissemdfent().nom}" >

        <p:messages id="msgs" />

        <h:panelGrdsfsdid columns="9" style="madffrgin-top:10px;">
            <h:outputLabel for="desigdfsnation" value="Designation: *"
                style="margin-right: 34px;" />
            <p:inputText id="designation" value="#{etudeBean.model.designation}"
                required="true" label="Designation">
                <f:validateLength minimum="2" />
            </p:inputText>
            <p:message for="designation" display="icon" />


            <h:outputLabel for="dateRealisation" value="Date Realisation: *    "
                style="margin-right: 34px;margin-left:34px;" />
            <p:calendar value="#{etufsddeBdsdsfean.model.dateRealisation}"
                pattern="dd.MM.yyyy" />

        </h:panelGrid>

        <p:commandButton valudfse="Save" update="panel"
            action="#{etudeBean.save()}" />
    </p:panel>
</h:form>

have one any idea please help me and thank you very much

LarsBauer
  • 1,539
  • 18
  • 23
user3578199
  • 1
  • 2
  • 5

1 Answers1

1

You have to add the growl to the update attribute of your commandButton, aswell. Like this:

<p:growl id="idgrowl"/>
...
<p:commandButton value="Save" update="growl" action="#{etudeBean.save()}" />

And in your managed bean add the FacesMessage the following way:

FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO,"Etude"+etude.getDesignation()+"modifiée avec succes","Mot de passe ancienne non valide: ");
FacesContext.getCurrentInstance().addMessage(null,msg);

This should work.

LarsBauer
  • 1,539
  • 18
  • 23
  • LarsBauer this does not work i obtain this error message: javax.servlet.ServletException: Cannot find component with expression "growl" referenced from "j_idt46". javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) please give me another solution becquse this one is not work – user3578199 Jun 06 '14 at 13:15
  • Your growl is located outside the panel in which the commandButton is nested. Just move the growl inside the panel, too. And tell me what happens then. – LarsBauer Jun 06 '14 at 13:17
  • the same error javax.servlet.ServletException: Cannot find component with expression "growl" referenced from "j_idt46". javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) – user3578199 Jun 06 '14 at 13:23
  • the problem is not update="growl" but update="idgrowl" now the message display into the tow component growl and p:messages i want display the message only in the growl commponent u undrestand me – user3578199 Jun 06 '14 at 13:26
  • The problem is that both components, growl and messages, are displaying FacesMessag sent from your managed bean. If you just want to update the growl remove "panel" from the update attribute of your commandButton: `` Or do you also have to update the panel, too? Sorry, I didn't understand your question properly from the beginning. – LarsBauer Jun 07 '14 at 15:29
  • probably you want to say check with attention update attribute which must have the id of the growl – Aditzu Jan 06 '15 at 14:59