title: @FacesConverter prevents method call of p:selectOneMenu and p:ajax
body: <p>I have a weird problem with a custom <code>@FacesConverter</code> with JBoss-7.1.0.CR1b during an AJAX call in <code>p:selectOneMenu</code> (Primefaces 3.0).</p>
  
  <p>The simplified Converter looks like this, there are no NPE or other exceptions in this class</p>
  
  <pre><code>@FacesConverter("MyConverter")
  public class MyConverter implements Converter
  {      
    public Object getAsObject(FacesContext fc, UIComponent uic, String value)
    {
      logger.debug("getAsObject value: "+value);
      if (submittedValue.trim().equals("")) {return null;}
      else
      {           
        MyEjb ejb = new MyEjb();
        ejb.setId(Long.parseLong(value()));
        return ejb;  //**** alternative with return null; ****
      }
    }  
    public String getAsString(FacesContext fc, UIComponent uic, Object value)
    { 
      if (value == null || value.equals("")) {return "";}
      else
      {
          MyEjb ejb = (MyEjb)value;
          return ""+ejb.getId(); 
      }  
    }  
  }
  </code></pre>
  
  <p>The converter is used in a <code>p:selectOneMenu</code>:</p>
  
  <pre><code>&lt;h:form&gt;  
    &lt;p:selectOneMenu value="#{clientBean.selected}" converter="MyConverter"&gt;
      &lt;f:selectItems value="#{clientBean.all}" var="my"
                     itemLabel="#{my.name}" itemValue="#{my}"/&gt;
        &lt;p:ajax listener="#{clientBean.changed}" /&gt;  
    &lt;/p:selectOneMenu&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>That's not rocket engineering, the changed method simply makes a debug:</p>
  
  <pre><code>public void changed()
  {
    logger.info("changed() "+selected);
  }
  </code></pre>
  
  <p>But now the annoying part: The <code>changed()</code> is never called with the code like above, but I get the converter invoked <em>three</em> times:</p>
  
  <pre><code>12:37:51,500 DEBUG getAsObject value: 35
  12:37:51,502 DEBUG getAsObject value:
  12:37:51,503 DEBUG getAsObject value:
  </code></pre>
  
  <p>If I change the <code>p:selectOneMenu value="#{clientBean.selectedId}"</code> to a <code>long selectedId</code> and don't use the Converter the method is called once. Even if I <code>return null</code> in <code>getAsObject()</code>the <code>changed()</code> is called (once). I don't assume it's Primefaces related, because I have the same behavior if I use <code>h:selectOneMenu</code> and <code>f:ajax</code>.</p>