title: custom converter not working primefaces
body: <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p:selectOneMenu value="#{schoolBean.newContactTO.contactType}" converter="contacttypeconverter"&gt;
   &lt;f:selectItem itemLabel="select type"&gt;&lt;/f:selectItem&gt;
   &lt;f:selectItems  value="#{schoolBean.contactTypesConstant.data}" var="contacttype" itemLabel="#{contacttype.type}" itemValue="#{contacttype}"&gt;&lt;/f:selectItems&gt;
  &lt;/p:selectOneMenu&gt;
  &lt;p:commandButton value="submit" actionListener="#{schoolBean.saveNewContactTO}"&gt;&lt;/p:commandButton&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am using custom converter for SelectOneMenu in PrimeFaces. The converter works well for getAsString() but for getAsObject I am not sure what goes wrong.
  The primefaces UI just gets hanged after this, and henceforth nothing works like I am using dialogs and it doesn't work after that.</p>
  
  <p>Here is my custom converter file:</p>
  
  <pre><code>@FacesConverter("contacttypeconverter")
  public class ContactTypeConverter implements Converter {
  @Override
  public Object getAsObject(FacesContext context, UIComponent component,String type) {
      ContactTypeTO result=null;
          System.out.println("type:"+type);
           if(component instanceof SelectOneMenu){
                      result = new ContactTypeTO();
                      result.setType(""+type);
                      System.out.println("result:"+result);
           }  
          System.out.println(""+result.getType());
      return result;
  }
  @Override
  public String getAsString(FacesContext context, UIComponent component,Object value) {
      String result = "";
      if( value instanceof ContactTypeTO){
          result = ((ContactTypeTO)value).getType();  
      }
      return result;
  }}
  </code></pre>
  
  <p>below is ContactTypeTO</p>
  
  <pre><code>public class ContactTypeTO {
  
  private String type;
  
    public String getType() {
       return type;
    }
  
    public void setType(String type) {
       this.type = type;
    }
  }
  </code></pre>
  
  <blockquote>
    <p>schoolBean.newContactTO.contactType is of type ContactTypeTO (as above)</p>
  </blockquote>
  
  <p>In getAsObject I am returning a new ContactTypeTO object but I can't figure out why the converter is not able to assign the value to schoolBean.newContactTO.contactType in SelectOneMenu. 
  After I submit, saveNewContactTO doesn't gets execute.
  The getAsObject method execute as required and also the result variable has proper data while returning.
   I think there is some issue while converting but I can't figure it out.  </p>