4 Replies Latest reply on Sep 28, 2011 9:06 PM by hantsy

    RichFaces4 autocomplete does not work..

    hantsy

      I tried to migrate another seam2 page to seam3.
      There is a autocomplete in the page...


      <p:input id="toAddress" label="#{messages['Message.To']}"
                               required="true">
                               <rich:autocomplete value="#{composeAction.toAddress}"
                                    autofill="false"
                                    autocompleteMethod="#{composeAction.autocomplete}" 
                                    var="recipient" 
                                    fetchValue="#{recipient}"
                                    minChars="1" 
                                    tokens=","
                                    layout="div"
                                    mode="client"
                                    required="true">                         
                                    <h:outputText value="#{recipient}" style="font-style:bold" />                         
                               </rich:autocomplete>
                          </p:input>
      



      The composeAction is conversation scoped.


      @Named("composeAction")
      @ConversationScoped
      @Stateful
      public class ComposeAction {
           @Inject
           EntityManager em;
      
           @SuppressWarnings("unchecked")
           private List<MessageRecipient> autocomplete(String keyword) {
                log.debug("searche by keyword #"+ keyword);
      
                String sql = "select new com.telopsys.siorc.model.MessageRecipient(e.vessel.name, e.email) from VesselEmail e where e.vessel.stat='A' and (e.vessel.name like :keyword or e.email like :keyword)";
                log.debug("sql statement@ #"+ sql);
                log.debug("em@ #"+ em);
                Query query = em.createQuery(sql);
                ......
                return results;
           }
      
      
      
      }
      




      The problem is the em is null at runtime...


      I got a NullPointerException at the line


      Query query = em.createQuery(sql);