I've already checked BalusC suggestions on commandButton/commandLink/ajax action/listener method not invoked or input value not updated, But i can't get my commandButton to get fired whenever i add a selectOneMenu dropdownlist
Here is my form:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/template/template.xhtml">
<ui:define name="content">
<h:form>
<h:messages />
<h:panelGrid columns="2">
<h:outputLabel value="Cin" />
<h:inputText value="#{addEmployeeBean.cin}" />
<h:outputLabel value="Nom" />
<h:inputText value="#{addEmployeeBean.nom}" />
<h:outputLabel value="Prenom" />
<h:inputText value="#{addEmployeeBean.prenom}" />
<h:outputLabel value="Login" />
<h:inputText value="#{addEmployeeBean.login}" />
<h:outputLabel value="Password" />
<h:inputSecret value="#{addEmployeeBean.password}" />
<h:outputLabel value="Id_Contrat" />
<h:inputText value="#{addEmployeeBean.idContrat}" />
<h:outputLabel value="Salaire" />
<h:inputText value="#{addEmployeeBean.salaire}" />
<h:outputLabel value="laboratoire:" />
<h:selectOneMenu value="#{addEmployeeBean.laboSelectionne}">
<f:selectItems value="#{addEmployeeBean.labos}" var="lab"
itemLabel="#{lab.nom}" itemValue="lab">
</f:selectItems>
</h:selectOneMenu>
<h:commandButton action="#{addEmployeeBean.ajouterEmploye()}"
value="Ajouter" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
And here is my managed bean:
@ManagedBean
@RequestScoped
public class AddEmployeeBean {
private String cin;
private String nom;
private String prenom;
private String login;
private String password;
private int idContrat;
private float salaire;
private List<Labo> labos;
private Labo laboSelectionne;
@EJB
GererLaboServiceLabo gererLaboServiceLocal;
@EJB
GererEmployeeServiceLocal employeeServiceLocal;
@PostConstruct
public void init(){
labos= gererLaboServiceLocal.listLabo();
laboSelectionne = new Labo();
}
public String ajouterEmploye() {
Employe employe = new Employe();
Contrat contrat = new Contrat();
contrat.setId(idContrat);
contrat.setSalaire(salaire);
employe.setCin(cin);
employe.setContrat(contrat);
employe.setLogin(login);
employe.setNom(nom);
employe.setPassword(password);
employe.setPrenom(prenom);
System.out.println(laboSelectionne.getNom());
employe.setLabo(laboSelectionne);
employeeServiceLocal.creerEmployee(employe);
return null;
}