title: jsf selectOneMenu converter gets list of items as value
body: <p>I have a jsf 2 select input with a converter tied to the selectentries.  My object has an id field that is a long that should be the value.  When my converter is called, it gets called with the whole list of select items (<code>List&lt;SimpleEntityGroup&gt;</code>) instead of the <code>SimpleEntityGroup</code> so I can just return the <code>.getId()</code> of the group.</p>
  <p>The debug output is:</p>
  <blockquote>
  <p>Converting to String</p>
  <p>[SimpleEntityGroup [id=1, name=Group 1], SimpleEntityGroup [id=2, name=Group 2], SimpleEntityGroup [id=3, name=Group 3]]</p>
  </blockquote>
  <p>I am expecting the method to be called 3 times with a single SimpleEntityGroup each time, not all 3 as a list at once.  The method is supposed to return a String, and if I return &quot;1&quot; then all my values in the select are one, so I know it is using the converter in the right spot.  Why is it calling it like this?</p>
  <pre><code>&lt;h:selectOneMenu value=&quot;#{simpleEntityBacking.simpleEntity.group}&quot; converter=&quot;SimpleEntityGroupConverter&quot;&gt;
      &lt;f:selectItems value=&quot;#{simpleEntityBacking.groups}&quot; var=&quot;c&quot;
          itemLabel=&quot;#{c.name}&quot; itemValue=&quot;#{c.id}&quot; /&gt;
  &lt;/h:selectOneMenu&gt;
  </code></pre>
  <p>Here is my backing bean - getters and setters and all omitted:</p>
  <pre><code>public class SimpleEntityBacking {
      private static final Logger L = Logger.getLogger(SimpleEntityBacking.class);
  
      @ManagedProperty(value=&quot;#{simpleEntity}&quot;)
      private SimpleEntity simpleEntity;
      
      @ManagedProperty(value=&quot;#{groups}&quot;)
      private List&lt;SimpleEntityGroup&gt; groups;
      
      @EJB
      private SimpleEntityDao ed;
      
      /**
       * 
       */
      public SimpleEntityBacking() {
          
      }
  </code></pre>
  <p>Here's my converter:</p>
  <pre><code>/* (non-Javadoc)
       * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
       */
      @Override
      public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
          return ed.getGroupById(new Long(arg2));
      }
  
      /* (non-Javadoc)
       * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
       */
      @Override
      public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
          L.debug(&quot;Converting to String&quot;);
          L.debug(arg2);
          SimpleEntityGroup g = (SimpleEntityGroup) arg2;
          return g.getId().toString();
      }
  </code></pre>