• Post Reply Bookmark Topic Watch Topic
  • New Topic

Primefaces row editing not working properly  RSS feed

 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,I am trying to perform row editing on primefaces datatable.I am fetching all the values of the datatable from database.In onEdit method i am just trying to fetch the primary key value of the row being edited .When i try to edit or cancel edit on clicking the tick or cross marks i am getting following exception.I am a newbie in JSF,please help on how to do row editing which can update the values to database.

stacktrace of the error



Aug 22, 2013 3:56:56 AM com.sun.faces.context.PartialViewContextImpl processPartial
INFO: java.lang.NullPointerException
java.lang.NullPointerException
at org.primefaces.component.datatable.feature.SelectionFeature.decodeMultipleSelection(SelectionFeature.java:51)
at org.primefaces.component.datatable.feature.SelectionFeature.decode(SelectionFeature.java:40)
at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:57)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
at org.primefaces.component.api.UIData.processDecodes(UIData.java:228)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:507)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at org.primefaces.component.api.UIData.visitTree(UIData.java:639)
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:377)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:252)
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.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(Unknown Source)



My JSF code snippet




My managed bean


 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of suggestions:

1. Don't use Request scope. It's almost 100% useless in JSF. Use View or Session scope.

2. Don't point the table's value= attribute at a raw collection/array. Wrap the collection in a DataModel and reference the DataModel object in your xhtml. You action methods can then use the getRowData() method to access the collection's row data for the selected row. Which typically includes the key value as one of its properties.

3. Seriously consider using a database connection pool for your JDBC connections. J2EE is an expensive platform to develop for, so you might as well use its features to your advantange.
 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim for your useful suggestion.I will definitely implement the things mentioned by you.For the row editing not working in this example i forgot to add selection attribute to the datatable and now it is working fine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!