title: selectOneMenu selected value
body: <p>Well, I need some clarification on selectOneMenu tag, using EL expression to get/set values</p>
  
  <pre><code>        &lt;h:selectOneMenu id="variantsMenu"
              value="#{missionHandler.selectedVariant}"
              converter="#{missionHandler.variantConverter}"&gt;
              &lt;f:selectItem itemLabel="-- Select a Variant --" /&gt;
              &lt;f:selectItems value="#{missionHandler.variants}" var="variant"
                  itemValue="#{variant}" itemLabel="#{variant.commercialName}" /&gt;
          &lt;/h:selectOneMenu&gt;
  </code></pre>
  
  <p>I have this code, it displays a list containing ("-- Select a Variant--", Variant 1, Variant 2, ... Variant n)
  When I click on a Variant, I would expect the <code>selectedVariant</code> property in the <code>missionHandler</code> managedBean to be updated automatically. But this is not the case. The <code>variantConverter</code> converter is not even called to convert the String "variant.commercialName" to a real <code>Variant</code> object.
  The variant object implements <code>hashCode()</code> and <code>equals()</code></p>
  
  <ul>
  <li>What concept of EL expression /  tag am I missing ?</li>
  <li><p>What would be the solution to my update problem ?</p>
  
  <p>EDIT :
  managedBean (simplified)</p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  public class MissionHandler implements Serializable {
  
  private static final long serialVersionUID = 2462652101518266609L;
  
  private List&lt;FlightFeasibilityException&gt; exceptions;
  
  @EJB
  private VariantDao variantDao;
  
  private Variant selectedVariant;
  
  private List&lt;Variant&gt; variants;
  
  private VariantConverter variantConverter;
  
  public MissionHandler() {
      /** Create an empty list of exceptions */
      exceptions = new ArrayList&lt;FlightFeasibilityException&gt;();
  }
  
  @PostConstruct
  public void init() {
      System.out.println("init done");
  }
  
  public List&lt;FlightFeasibilityException&gt; getExceptions() {
      return exceptions;
  }
  
  public void setExceptions(List&lt;FlightFeasibilityException&gt; exceptions) {
      this.exceptions = exceptions;
  }
  
  public Variant getSelectedVariant() {
      return selectedVariant;
  }
  
  public void setSelectedVariant(Variant selectedVariant) {
      this.selectedVariant = selectedVariant;
  }
  
  public List&lt;Variant&gt; getVariants() {
      return variants;
  }
  
  public void setVariants(List&lt;Variant&gt; variants) {
      this.variants = variants;
  }
  
  public VariantConverter getVariantConverter() {
      return variantConverter;
  }
  
  public void setVariantConverter(VariantConverter variantConverter) {
      this.variantConverter = variantConverter;
  }
  </code></pre>
  
  <p>}</p></li>
  </ul>
  
  <p>Converter</p>
  
  <pre><code>@FacesConverter(forClass=Variant.class)
  public class VariantConverter implements Converter, Serializable {
  
      private static final long serialVersionUID = 7053414108213420057L;
  
      private VariantDao variantDao=new VariantDaoImpl();
  
      @Override
      public Object getAsObject(FacesContext context, UIComponent component,
              String value) {
          System.out.println("convert to Object " + value);
          Variant variant = variantDao.find(value);
          System.out.println("got variant " + variant.getCommercialName());
          return variant;
      }
  
      @Override
      public String getAsString(FacesContext context, UIComponent component,
              Object value) {
          System.out.println("convert to String " + value);
          return ((Variant) value).getCommercialName();
        }
  
      }
  </code></pre>
  
  <p>and the xhtml file</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"&gt;
  &lt;h:head&gt;
      &lt;title&gt;Mission Page&lt;/title&gt;
      &lt;link href="./css/styles.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;rich:panel&gt;
          &lt;f:facet name="header"&gt;
              Mission Information
          &lt;/f:facet&gt;
          &lt;a4j:outputPanel layout="block"&gt;
              &lt;h:form&gt;
                  &lt;h:outputText style="font-weight: bold;" value="Mission Id: " /&gt;
                  &lt;h:inputText id="missionId" label="missionId"
                      value="#{missionHandler.mission.id}" disabled="true"
                      style=" width : 50px;"&gt;
                  &lt;/h:inputText&gt;
                  &lt;h:outputText style="font-weight: bold;" value="Mission Status: " /&gt;
                  &lt;h:inputText id="missionStatus" label="missionStatus"
                      value="#{missionHandler.mission.status}" disabled="true"&gt;
                  &lt;/h:inputText&gt;
              &lt;/h:form&gt;
              &lt;br /&gt;
              &lt;h:form&gt;
                  &lt;h:selectOneMenu value="#{missionHandler.selectedAircraftType}"
                      converter="#{missionHandler.acTypeConverter}"&gt;
                      &lt;f:selectItem itemLabel="-- Select an A/C Type --" /&gt;
                      &lt;f:selectItems value="#{missionHandler.aircraftTypes}" var="type"
                          itemValue="#{type}" itemLabel="#{type.typeOACI}" /&gt;
                      &lt;f:ajax listener="#{missionHandler.changeSelectedAircraftType}"
                          render="@form" /&gt;
                  &lt;/h:selectOneMenu&gt;
                  &lt;h:selectOneMenu id="variantsMenu"
                      value="#{missionHandler.selectedVariant}"
                      converter="#{missionHandler.variantConverter}"
                      rendered="#{not empty missionHandler.selectedAircraftType}"&gt;
                      &lt;f:selectItem itemLabel="-- Select a Variant --" /&gt;
                      &lt;f:selectItems value="#{missionHandler.variants}" var="variant"
                          itemValue="#{variant}" itemLabel="#{variant.commercialName}" /&gt;
                  &lt;/h:selectOneMenu&gt;
              &lt;/h:form&gt;
          &lt;/a4j:outputPanel&gt;
      &lt;/rich:panel&gt;
  ….. A LOT OF OTHER THINGS …..
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>