1 Reply Latest reply: Jul 19, 2012 10:14 AM by Pavol Pitonak RSS

    rich:pickList Converter.getAsObject -> problems with Injection

    Martin Book Newbie

      Hello,

       

      i have following Picklist:

       

      <rich:pickList id="acc1" value="#{passwdDetail.uFuncSelected}" ...
      <f:selectItems value="#{passwdDetail.items.kUserFunktionItems}" ...
      <f:converter converterId="RoleConverter" />    
      </rich:pickList>
      

       

      I have tried to use @Inject or @EJB to inject Persistence class. Both cause Nullpointer-Exception.

      @FacesConverter("RoleConverter") 
      public class RoleConverter implements Converter{
                                                                        
       @PersistenceContext
       EntityManager em;
       //@Inject
       @EJB
       private PasswdProducer passwdProducer;
       @Override
       public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
        //List <KUserFunktion> kuser=em.createQuery( "from KUserFunktion").getResultList(); 
        List <KUserFunktion> kuser=passwdProducer.findAll(KUserFunktion.class);
        for (KUserFunktion userFunk : kuser ) {
         if (String.valueOf(String.valueOf(userFunk.getId())).equals(arg2)) {
          return userFunk;
         }
        }
        return null;
       }