1
votes

I'm using prime faces data table in my application where i have a checkbox column in datatable to select certain rows and send the values to back bean but it always passes null values ,could any one suggest what's wrong with my code

 <p:dataTable id="tblStatusSearch" var="item"
      selection="#{StatusAction.listBEeans}" 
        value="#{bondLocationStatusAction.listLocationEBeans}"
     rowKey="#{item.LocationId}">
         <p:column selectionMode="multiple"/>

BackBean :

private List<LocationEBean> listBEeans;

public List<LocationEBean> getListBEeans() {
    return listBEeans;
}

public void setListBEeans(List<LocationEBean> listBEeans) {
    this.listBEeans = listBEeans;
}
public void ReSend(){

  listBEeans=new ArrayList<LocationEBean>();
  System.out.println("listBEans:"+listBEeans);
  msgProcBusServ.reSendMsg(listBEeans);

}

Errr Log

INFO: java.lang.NullPointerException
java.lang.NullPointerException
    at java.lang.reflect.Array.newArray(Native Method)
    at java.lang.reflect.Array.newInstance(Array.java:52)
    at org.primefaces.component.datatable.DataHelper.decodeMultipleSelection(DataHelper.java:268)
    at org.primefaces.component.datatable.DataHelper.decodeSelection(DataHelper.java:240)
    at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:72)
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
    at javax.faces.component.UIData.processDecodes(UIData.java:1162)
    at org.primefaces.component.datatable.DataTable.processDecodes(DataTable.java:554)
    at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:506)
    at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at javax.faces.component.UIData.visitTree(UIData.java:1411)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at javax.faces.component.UIForm.visitTree(UIForm.java:371)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376)
    at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:252)
    at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
    at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
    at org.openfaces.ajax.PartialViewContext.processPartial(PartialViewContext.java:131)
    at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
    at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
    at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:66
1
What is the scope of your bean? is that @ViewScoped?Mehdi
Could you please paste your bean code here? and try this : private List<LocationEBean> listBEeans = new ArrayList<LocationEBean>();Mehdi
@heidarzadeh, i have edited my bean ,thanks :)Bernad Ali
try to make listBEean an array like this private LocationEBean[] listBEeans;Daniel

1 Answers

3
votes

INMO selection should point to an array instead of array list

try to make listBEean an array like this

private LocationEBean[] listBEeans;

take a look at the showcase

DataTable - Multiple Row Selection