title: Unable to inject a CDI bean in Primefaces LazyDataModel implementation class
body: <p>Any CDI bean I inject in the implementation class of <code>org.primefaces.model.LazyDataModel</code>, turns out null. The lazy model implementation class itself is a CDI <code>@Named</code> bean with scope <code>@javax.faces.bean.ViewScoped</code>. It looks like this:</p>
  
  <pre><code>    @Named("myLazyModel")
      @ViewScoped
      Class MyLazyModel extends LazyDataModel implements Serializable {
  
      public MyLazyModel() {
  
      }
  
      @Inject
      AnotherCdiBeanClass injectedObj;
  
      public AnotherCdiBeanClass getInjectedObj() {
          return injectedObj;
      }
  
      public AnotherCdiBeanClass setInjectedObj(AnotherCdiBeanClass anotherCdiBeanClassObj) {
          this.injectedObj = anotherCdiBeanClassObj;  
      }
  
  
      public void someMethod() {
         getInjectedObj(); // Its NULL, why?
      }
  
  
  }
  </code></pre>
  
  <p>I did get a warning in eclipse from Java while injecting in lazymodel implementation bean class. Warning was something like that <strong>the lazymodel class bean can not proxied by the container as it does not contain non-private no-arg constructor and the bean is not a normal scoped bean</strong>(something like that).</p>
  
  <p>There is another problem, in the LazyDataModel implementation class, I have set the rowCount to the size of the actual data list's dynamic size (size after filtering in grid). But then after instantiating the lazymodel implementation class outside in some CDI bean gives me a rowCount of zero.</p>
  
  <p><code>new MyLazyModel(actualDataList).getRowCount()</code> -> 0</p>
  
  <p>Upon debugging I found it does contain the complete actual data list but rowCount is still zero.</p>
  
  <p>I needed on the go <code>rowCount</code> of the filtered rows as I type and filter them on a primefaces grid so that I can dynamically update an outputLabel with the currently filtered grid's rowCount value.</p>
  
  <pre><code>int currentRowCount = actualDataListInLazyModelClass.size();
  </code></pre>
  
  <p>I will be updating the outputLabel like this:</p>
  
  <pre><code>org.primefaces.context.RequestContext.getCurrentInstance.update("myForm:recordCountLabel");
  </code></pre>
  
  <p>But before that I need to set property of an injected bean (View's backing bean) with the rowCount value but the injected bean itself turns out null as said before.</p>
  
  <pre><code>getInjectedObj().setNoOfRecords(Integer.toString(currentRowCount));
  </code></pre>
  
  <p>// NULL POINTER because getInjectedObj() is null</p>
  
  <p>Sorry if I have described things more or less due to limitations at my end.</p>