2 Replies Latest reply on Dec 27, 2007 12:30 PM by Felix Khazin

    h:selectOneMenu and Ajax4jsf problem

    Felix Khazin Newbie

      Hi,

      I'm trying to change a rich:dataTable based on which dropdown item is selected. Here is my drop down:

      <h:selectOneMenu value="#{customerList.selectedReseller}">
       <a4j:support event="onchange" reRender="resultTableDiv" />
       <s:selectItems value="#{resellerList.resultList}" var="reseller" label="#{reseller.reseller}" noSelectionLabel="Select..."/>
       <s:convertEntity />
      </h:selectOneMenu>


      My Bean:

      @Stateful
      @Name("customerList")
      public class CustomerListAction implements CustomerList
      {
       private Reseller selectedReseller;
       private List<Customer> customerListByReseller;
      
       @PersistenceContext
       private EntityManager em;
      
       @Logger
       private Log log;
      
       @In
       private FacesMessages facesMessages;
      
       @Create
       public void getCustomerByResellerId()
       {
       try
       {
       customerListByReseller = em.createQuery("select customer from Customer customer where reseller=:reseller")
       .setParameter("reseller", selectedReseller).getResultList();
       }
       catch(Exception e)
       {
       log.error("An error occured: ", e);
       }
       }
      
       @Destroy @Remove
       public void destroy()
       {
       }
      
       public void setSelectedReseller(Reseller selectedReseller)
       {
       this.selectedReseller = selectedReseller;
       }
      
       public Reseller getSelectedReseller()
       {
       return selectedReseller;
       }
      
       public void setCustomerListByReseller(List<Customer> customerListByReseller)
       {
       this.customerListByReseller = customerListByReseller;
       }
      
       public List<Customer> getCustomerListByReseller()
       {
       return customerListByReseller;
       }
      }


      The rerender works fine. I can see the a4j rerendering because the datatable is hitting my "getCustomerByResellerId()" method (I see hibernate querying the database). Problem is with selectedReseller. It keeps coming back as Null. So the h:selectOneMenu doesn't place the selected Item into selectedReseller.

      Anyone see anything wrong with this and why this wouldn't work?

      Thank you very much,
      Felix