title: selectOneMenu wont update when itemValue is set to an Object
body: <p>I'm trying to create a selectOneMenu using primefaces 5.2, the list items are loaded from a database, and their type is an Object which contains other attributes, I wanted to copy <a href="http://www.primefaces.org/showcase/ui/input/oneMenu.xhtml" rel="nofollow">the primefaces showcase method</a> (the Advanced one), but the selected value is never assigned, here is my code: </p>
  
  <pre><code> &lt;h:form id="f"&gt;
                      &lt;p:selectOneMenu id="advanced" value="#{expertiseController.selectedExpertise}" converter="expertiseConverter"&gt;
                          &lt;f:selectItems value="#{expertiseController.expertises}" var="exp" itemLabel="#{exp.id}" itemValue="#{exp}" /&gt;
                          &lt;p:ajax update="test" /&gt;
                      &lt;/p:selectOneMenu&gt;
  
                      &lt;p:outputLabel id="test" value="#{expertiseController.selectedExpertise.id}"/&gt;
                  &lt;/h:form&gt;
  </code></pre>
  
  <p>the bean:</p>
  
  <pre><code>@Named(value = "expertiseController")
  @ViewScoped
  public class ExpertiseController implements Serializable {
  
      private Expertise selectedExpertise = new Expertise();
      private List&lt;Expertise&gt; expertises = Expertise.getAllExpertiseTypes();
  ....
  getters ..
  </code></pre>
  
  <p>the Converter:</p>
  
  <pre><code>FacesConverter("expertiseConverter")
  public class ExpertiseConverter implements Converter {
  
      public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
          if(value != null &amp;&amp; value.trim().length() &gt; 0) {
              try {
                  return Expertise.getById(value);
              } catch(Exception e) {
                  e.printStackTrace();
                  return null;
              }
          }
          else {
              return null;
          }
      }
  
      public String getAsString(FacesContext fc, UIComponent uic, Object object) {
          if(object != null) {
              return String.valueOf(((Expertise) object).getId());
          }
          else {
              return null;
          }
      }   
  }   
  </code></pre>
  
  <p>but the outputLabel is never set, and the setter method of the <code>selectedExpertise</code> is never fired.
  Now this only happenes when i set the itemValue to <code>#{exp}</code>, but when i set it like to <code>#{exp.id}</code> (and change the selectOneMenu value ofcourse) everything works.
  I even checked the converter values, they are both fine.
  And the problem is when i try the primefaces example it works well! when i change it to my Object and converter it dosnt!</p>
  
  <p>What am i missing or doing wrong here?</p>
  
  <p><strong>UPDATE:</strong>
  I just figured out that you have to return in the converter the <strong>same</strong> object from the list, here s what i did, 
  I injected the <code>ExpertiseController</code> in the <code>ExpertiseConverter</code>, then i loop through the list of the <code>ExpertiseController</code> and returned the same object (same address i guess or something), here is the code: </p>
  
  <pre><code>import com.medisecretaire.controller.ExpertiseController;
  import com.medisecretaire.model.Expertise;
  import java.io.Serializable;
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.convert.Converter;
  import javax.faces.convert.FacesConverter;
  import javax.inject.Inject;
  
  @FacesConverter("expertiseConverter")
  public class ExpertiseConverter implements Converter, Serializable {
  
      @Inject
      private ExpertiseController controller;
  
  
      public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
          System.out.println(controller.getExpertises());
          if(value != null &amp;&amp; value.trim().length() &gt; 0) {
              try {
                  for (Expertise expertise : controller.getExpertises()) {
                      if(expertise.getId().equalsIgnoreCase(value)){
                          return expertise;
                      }
                  }
  
                  return null;
              } catch(Exception e) {
                  return null;
              }
          }
          else {
              return null;
          }
      }
  
      public String getAsString(FacesContext fc, UIComponent uic, Object object) {
          if(object != null) {
              return String.valueOf(((Expertise) object).getId());
          }
          else {
              return null;
          }
      }   
  }       
  </code></pre>
  
  <p>But is there a better way to do it? i didnt like the "injecting" part ... or is it normal?</p>
  
  <p><strong>UPDATE 2:</strong>
  when i add <code>filter="true"</code> it does not work anymore .. this is confusing ...   </p>
  
  <p><strong>UPDATE 3:</strong>
  I knew there was a better way! so i grabbed the <code>UIComponent</code> extracted the <code>SelectOneMenu</code> iterated over its children and found the <code>UISelectItems</code>, from there i found the same objects stored in a list, here is the code: </p>
  
  <pre><code>public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
          List list = null;
  
          SelectOneMenu menu = (SelectOneMenu) uic;
          for (UIComponent comp : menu.getChildren()) {
              if (comp instanceof UISelectItems) {
                  UISelectItems item = (UISelectItems) comp;
                  if (item.getValue() instanceof List) {
                      list = (List) item.getValue();
                  }
              }
          }
          //Do something with the list
  </code></pre>
  
  <p>and ever with the filer attribute it works now.</p>