title: lazy datatable's rowselect event object is always null
body: <p>I'm trying to use the <code>p:datatable</code> to list a previously search result and then select a row to get displayed on a show dialog (as shown in showcase, <a href="http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml" rel="nofollow noreferrer">http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml</a>).
  But <code>SelectEvent.getObject()</code> of ajax event "rowSelect" returns always <code>null</code> and current row is never selected.</p>
  
  <p>This is the stack trace:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at com.gestion.projet.web.jsf.ProjetComponentImpl.onRowSelect(ProjetComponentImpl.java:92)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy58.onRowSelect(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy10.onRowSelect(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
      ... 38 more
  </code></pre>
  
  <p>This is my xhtml file:</p>
  
  <pre><code>&lt;p:dataTable var="current" value="#{ProjetComponent.lazyModel}" 
                  paginator="true" rows="10" 
                  paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                  rowsPerPageTemplate="5,10,15" selectionMode="single"
                  selection="#{ProjetComponent.projet}" id="projetTable" lazy="true"&gt;
                  &lt;p:ajax event="rowSelect" listener="#{ProjetComponent.onRowSelect}"
                      update=":form:projetDetail" oncomplete="PF('projetDialog').show()" /&gt;
                  &lt;p:column headerText="Id" sortBy="#{current.idprojet}" filterBy="#{current.idprojet}"&gt;
                      &lt;h:outputText value="#{current.idprojet}" /&gt;
                  &lt;/p:column&gt;
                  &lt;p:column headerText="Nom" sortBy="#{current.nomprojet}"
                      filterBy="#{current.nomprojet}"&gt;
                      &lt;h:outputText value="#{current.nomprojet}" /&gt;
                  &lt;/p:column&gt;
  
              &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>And this is the method <code>onRowSelect</code> on <code>ProjetComponent</code> who contain the line 92:</p>
  
  <pre><code>@Scope("session")
  @Component("ProjetComponent")
  
  public class ProjetComponentImpl implements ProjetComponent {
  
      private Projet projet;
  
      @Autowired
      private ProjetService projetService;
  
      private LazyDataModel&lt;Projet&gt; lazyModel;
      /** 
       */
      public ProjetComponentImpl() {
      }
  
  
  
  
  
      @PostConstruct
          public void init() {
              //initialize the data here
              this.phases = new Phase();
              //similar for other fields
              this.utilisateurs =new Utilisateur();
              this.projet=new Projet();
              this.lazyModel = new LazyProjetDataModel(projetService.findAllProjets(-1, -1));
          }
  
      @Transactional
       public LazyDataModel&lt;Projet&gt; getLazyModel() {
          this.lazyModel = new LazyProjetDataModel(projetService.findAllProjets(-1, -1));
  
          return lazyModel;
      }
  
       @Transactional
      public void setLazyModel(LazyDataModel&lt;Projet&gt; lazyModel) {
          this.lazyModel = lazyModel;
      }
  @Transactional
      public void onRowSelect(SelectEvent event) {
      if (event != null){
  
              FacesMessage msg = new FacesMessage("Projet Selected", ((Projet) event.getObject()).getIdprojet().toString());//Line 92
              FacesContext.getCurrentInstance().addMessage(null, msg);
      }   }
  }
  </code></pre>
  
  <p>and this the <code>LazyProjetDataModel</code>:</p>
  
  <pre><code>public class LazyProjetDataModel extends LazyDataModel&lt;Projet&gt;  {
      private static final long serialVersionUID = 1L;
      private List&lt;Projet&gt; datasource;
  
      public LazyProjetDataModel(List&lt;Projet&gt; datasource) {
          this.datasource = datasource;
      }
  
      @Override
      public Projet getRowData(String rowKey) {
          for(Projet projet : datasource) {
              if(projet.getIdprojet().equals(rowKey))
                  return projet;
          }
  
          return null;
      }
  
      @Override
      public Object getRowKey(Projet projet) {
          return projet.getIdprojet();
      }
      @Override
      public List&lt;Projet&gt; load(int first, int pageSize, String sortField, SortOrder sortOrder, Map&lt;String, Object&gt; filters) {
          List&lt;Projet&gt; data = new ArrayList&lt;Projet&gt;();
  
          //filter
          for(Projet car : datasource) {
              boolean match = true;
  
              if (filters != null) {
                  for (Iterator&lt;String&gt; it = filters.keySet().iterator(); it.hasNext();) {
                      try {
                          String filterProperty = it.next();
                          Object filterValue = filters.get(filterProperty);
                          String fieldValue = String.valueOf(car.getClass().getField(filterProperty).get(car));
  
                          if(filterValue == null || fieldValue.startsWith(filterValue.toString())) {
                              match = true;
                      }
                      else {
                              match = false;
                              break;
                          }
                      } catch(Exception e) {
                          match = false;
                      }
                  }
              }
  
              if(match) {
                  data.add(car);
              }
          }
  
          //sort
          if(sortField != null) {
         //     Collections.sort(data, new LazySorter(sortField, sortOrder));
          }
  
          //rowCount
          int dataSize = data.size();
          this.setRowCount(dataSize);
  
          //paginate
          if(dataSize &gt; pageSize) {
              try {
                  return data.subList(first, first + pageSize);
              }
              catch(IndexOutOfBoundsException e) {
                  return data.subList(first, first + (dataSize % pageSize));
              }
          }
          else {
              return data;
          }
      }
  }
  </code></pre>
  
  <p>this is the screenshot of datatable:
  <img src="https://i.stack.imgur.com/o5VcB.png" alt="enter image description here">
  and this is what i get when i select a row:
  <img src="https://i.stack.imgur.com/frEsa.png" alt="enter image description here"></p>