1 Reply Latest reply on Jun 22, 2010 5:23 PM by Andreas Haumer

    Pojo can't be injected to Converter class

    Fabin Riako Newbie
      Hi All

      I am trying to create a create a Converter class for my SelectOneMenu. I created DbUtil calss for all database access. But I can't inject the DbUtil to my Converter class. Can anybody help me to solve this.

      Here is the sample code

      public class DBUtil {
           EntityManager entityManager;
           Log log;
           public Location findLocationById(String locationId)
                return entityManager.find(Location.class,Integer.valueOf(locationId));

      public class LocationConverter implements javax.faces.convert.Converter {     
           DBUtil dbUtil;
           public Object getAsObject(FacesContext context, UIComponent component, String value) {
                if((value!=null) && !value.toString().equals("--Select--"))
                     return dbUtil.findLocationById(value);
                     return null;

           public String getAsString(FacesContext context, UIComponent component, Object value) {          
                return value!=null && ! value.toString().equals("")  ? ((Location)value).toString() : null;