I have a form that consists of 3 dropdown and when i chose an item from the first dropdown the listener retrieve the list of the 2nd dropdown perfectly. But when i chose an item from the 2nd dropdown listener does not work and does not even mention the method of my bean.
Here is my form
<p:outputLabel for="structure" value="Structure"/>
<h:panelGroup >
<p:selectOneMenu id="structure" value="#{etpBean.idt_structure}" style="margin-bottom:10px;" required="true">
<p:ajax listener="#{etpBean.onRessourceChange}" update="affectation" />
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{etpBean.structures}" var="structure" itemValue="#{structure.idt_structure}" itemLabel="#{structure.nom}" />
</p:selectOneMenu>
</h:panelGroup>
<p:outputLabel for="affectation" value="les ressources affectee"/>
<h:panelGroup >
<p:selectOneMenu id="affectation" value="#{etpBean.idt_affectation}" style="margin-bottom:10px;" required="true">
<p:ajax listener="#{etpBean.onAffectationChange}" update="activite" />
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{etpBean.affectations}" var="affectation" itemValue="#{affectation.idt_affectation}" itemLabel="#{affectation.ressource.nom}" />
</p:selectOneMenu>
</h:panelGroup>
<p:outputLabel for="activite" value="Activite"/>
<h:panelGroup >
<p:selectOneMenu id="activite" value="#{etpBean.idt_parent}" style="margin-bottom:10px;" required="true">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{etpBean.activites}" var="activite" itemValue="#{activite.idt_parent}" itemLabel="#{activite.nom}" />
</p:selectOneMenu>
</h:panelGroup>
<p:outputLabel for="pes" value="charge effectué"/>
<h:panelGroup>
<p:inputText id="pes" value="#{etpBean.etp}" />
<p:slider for="pes" step="1" />
</h:panelGroup>
</p:panelGrid>
</p:panel>
</h:form>
And Here is my bean
@ManagedBean(name="etpBean")
@ViewScoped
public class EquivalentTempPleinBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Double etp;
private Date dateDebut;
private Date dateFin;
private Long idt_affectation;
private Long idt_parent;
private Long idt_ressource;
private Long idt_structure;
private Collection<Ressource> ressources;
private Collection<Structure> structures;
private Collection<Activite> activites;
private Collection<Affectation> affectations;
private ETP equivalentTempPlein = new ETP();
private Ressource ressource = new Ressource();
private Affectation affectation;
private Activite activite = new Activite();
private Structure structure;
@ManagedProperty(value = "#{ressourceService}")
private IRessourceService ressourceService;
@ManagedProperty(value = "#{structureService}")
private IStructureService structureService;
@ManagedProperty(value = "#{activiteService}")
private IActiviteService activiteService;
@ManagedProperty(value = "#{affectationService}")
private IAffectationService affectationService;
public EquivalentTempPleinBean() {
super();
}
@PostConstruct
public void init()
{
structures=structureService.listStructures();
}
// work perfeclty
public void onRessourceChange(){
System.out.println("On ressource Change");
structure =structureService.findStructureById(idt_structure);
affectations=affectationService.affectationByStructure(idt_structure);
//ressources=ressourceService.ressourceOnAffectation(idt_structure);
}
//dont work
public void onAffectationChange(){
System.out.println("##########################################################");
affectation=(Affectation) affectationService.findAffectationById(idt_affectation);
activites=activiteService.activiteOnAffectation(idt_structure,affectation.getDateDebut(),affectation.getDateFin());
}
//Getters and setters
}