1 Reply Latest reply on Oct 1, 2007 9:37 AM by Pete Muir

    no action called from a form because of selectOneMenu

    Vincent LAUGIER Newbie

      Hello,

      we struggle with a very weird problem for a few days now

      we have a two step registering process in the application

      in the second form the user can specify his roles, his manager, his company from three selectOneMenu

      if we remove the company choice part from the form everything works fine

      if we add it, or even if we put it all alone on the page the method in the manager bean is not called anymore !! (we have put a println at the beginning to check this) : we press the button, the page reload, that's all

      here is the xhtml page :

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf"
       xmlns:c="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich"
       xmlns:a="https://ajax4jsf.dev.java.net/ajax"
       xmlns:ec="http://jboss.com/products/seam/entityconverter/taglib"
       template="layout/template.xhtml">
      
      <ui:define name="body">
      
       <h:messages globalOnly="true" styleClass="message"/>
      
      
       <h:form id="createAccount" styleClass="edit">
      
      
      
       <rich:panel>
       <c:facet name="header">Informations complémentaires</c:facet>
      
      
       <div class="input">
       Nom du manager :
       <s:decorate id="managerSelection">
      
       <h:selectOneMenu id="SelectionMenuForManager" value="#{employee.manager}" >
      
       <s:selectItems value="#{employeeQuery.resultList}" var="row" label="#{row.account.fullname}" noSelectionLabel="Please Select..."/>
       <s:convertEntity />
      
       </h:selectOneMenu>
      
       </s:decorate>
       </div>
      
      
       <div class="input">
       <s:decorate id="roleSelection">
       <ui:define name="label">Ajout d'un rôle:</ui:define>
       <h:selectOneMenu id="SelectionMenuForRoles" value="#{role}" >
      
       <s:selectItems value="#{roleQuery.resultList}" var="row" label="#{row.name}" noSelectionLabel="Please Select..."/>
       <s:convertEntity />
      
       </h:selectOneMenu>
       </s:decorate>
      
       <h:commandButton value="Ajouter le rôle"
       action="#{accountManager.registerRole(role)}"/>
       </div>
      
       <div class="input">
       <h:dataTable value="#{account.roles}" var="row" >
       <h:column>
       #{row.name}
       </h:column>
       <h:column>
       <h:commandButton action="#{accountManager.removeRole(row)}" value="Retirer le rôle" />
       </h:column>
       </h:dataTable>
       </div>
      
      
       <div class="input">
       Nom de la société :
       <s:decorate id="companySelection">
       
       <h:selectOneMenu id="SelectionMenuForCompany" value="#{employee.company}" >
      
       <s:selectItems value="#{companyQuery.resultList}" var="row" label="#{row.name}" noSelectionLabel="Please Select..."/>
       <s:convertEntity />
      
       </h:selectOneMenu>
      
       </s:decorate>
       </div>
      
      
      
       <div style="clear:both"/>
      
      
      
       </rich:panel>
      
       <div class="actionButtons">
      
       <h:commandButton value="Enregistrer le compte employé"
       action="saveAccountAction"/>
       </div>
      
       </h:form>
      
      </ui:define>
      
      </ui:composition>
      



      this is the manager bean
      package fr.helmet.portal.manager;
      
      import fr.helmet.portal.entity.Account;
      import fr.helmet.portal.entity.Client;
      import fr.helmet.portal.entity.Employee;
      import fr.helmet.portal.entity.Role;
      import java.io.Serializable;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import javax.persistence.PersistenceContextType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.security.Restrict;
      import org.jboss.seam.core.FacesMessages;
      import org.jboss.seam.log.Log;
      
      @Stateful
      @Name("accountManager")
      
      public class AccountManagerBean implements AccountManager, Serializable {
      
       @Logger private Log log;
      
      
       @In FacesMessages facesMessages;
      
       @PersistenceContext(type=PersistenceContextType.EXTENDED)
       private EntityManager em;
      
       @In(required=false)
       @Out(required=false)
       private Account account ;
      
      
      
       @Out(required=false)
       @In(required=false)
       private Employee employee;
      
      
       @Out(required=false)
       @In(required=false)
       private Client client;
      
      
      
      
      
      
       @Destroy @Remove
       public void destroy() {}
      
      
      
       public Account getAccount() {
       return account;
       }
      
       public void setAccount(Account account) {
       this.account = account;
       }
      
      
       public void registerClient() {
       System.out.println("Entrée dans registerClient");
       Client client = new Client();
       System.out.println("Avant setAccount");
       System.out.println(account.getId() + account.getFullname());
       client.setAccount(account);
       System.out.println("Apres setAccount");
      
       em.persist(client);
       System.out.println("Enregistrement du client réussi !");
      
      
       }
      
      
      
       
       public void registerEmployee() {
      
       System.out.println("IN REGISTERING EMPLOYEE");
      
       Employee employee = new Employee();
      
       employee.setAccount(this.account);
      
       em.persist(employee);
      
       System.out.println("REUSSI !");
       }
      
      
       public void registerRole(Role role)
       {
      
       System.out.println("in registerRole");
       account.getRoles().add(role);
       }
      
       public void removeRole(Role role)
       {
       account.getRoles().remove(role);
       System.out.println("R?le supprim? de la commande");
       }
      
      
       public Employee getEmployee() {
       return employee;
       }
      
       public void setEmployee(Employee employee) {
       this.employee = employee;
       }
      
       @Restrict
       public String editClient(Client selectedClient) {
      
       //Client toEdit = em.merge(selectedClient);
       this.client = selectedClient;
       this.account = this.client.getAccount();
       //this.client = clt;
       //System.out.println("ID du client = " + this.client.getId()) ;
       //System.out.println("editAccount " + this.client.getAccount().getFullname());
       //facesMessages.add("editAccount " + this.client.getAccount().getFullname());
       //this.account = client.getAccount();
       return "createAccount";
       }
      
       public Client getClient() {
       return client;
       }
      
       public void setClient(Client client) {
       this.client = client;
       }
      
       public String testing(String str){
       //facesMessages.add("test !");
       System.out.println("Le message est " + str);
       return "createAccount";
       }
      
       public void updateAccount() {
       System.out.println("mise à jour");
       em.merge(account);
       }
      
      }
      
      



      hope it inspires some of you guys

      thanks