title: CDI Injection into a FacesConverter
body: <p>From just a few searches, this seems like a problem that has been around for a while.  I have written a FacesConverter that looks like the following.  The object <strong>Category</strong> is a JPA entity and <strong>CategoryControl</strong> is the DAO that fetches it.</p>
  
  <pre><code>@FacesConverter(value = "categoryConverter")
  public class CategoryConverter implements Converter {
  
  @Inject private CategoryControl cc;
  
  public CategoryConverter() { }
  
  @Override
  public Object getAsObject(FacesContext context, UIComponent component, String value) {
      if (cc != null) return cc.getByName(value);
      System.out.println("CategoryConverter().getAsObject(): no injection!");
      return null;
  }
  
  @Override
  public String getAsString(FacesContext context, UIComponent component, Object value) {
      if (!(value instanceof Category)) return null;
      return ((Category) value).getName();
  }
  
  }
  </code></pre>
  
  <p>As you probably guessed by now, I never get the injection.  I got this workaround from <a href="https://issues.apache.org/jira/browse/EXTCDI-127" rel="noreferrer">this page</a>, which looks like this.:</p>
  
  <pre><code>Workaround for this problem: create this method in your localeController: 
  
  public Converter getConverter() 
  { 
      return   FacesContext.getCurrentInstance().getApplication().createConverter("localeConverter"); 
  } 
  
  and use converter="#{localeController.converter}" in your h:selectOneMenu.
  </code></pre>
  
  <p>However I can't make this work either.  My backing bean creates and returns a converter all right, but it doesn't get the object injected into it.  </p>
  
  <p>I am using MyFaces CODI 1.0.1. With the current GlassFish/Weld container.  Can anyone suggest a solution before I re-code to not use a Converter?</p>