Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get row data from datatable  RSS feed

 
sneha patil
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..I am new to primefaces...i am using an datatable and every row has a selectonemenu as an column....and i wants to get selected data on submit button...
any help???
Thanks in advance...
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your datatable needs to have an associated DataModel object. The DataModel was mandatory in JSF1, but in JSF2 a lot of people take the easy way out and pass vanilla arrays and collections to the dataTable instead. That's OK for display-only, but in your case, it's not enough.

It's not that hard to use a DataModel and you gain a key benefit. The DataModel wraps the underlying array, List or whatever and maintains a row cursor. When the user clicks on a button and that button's action method fires, the action method can invoke the getRowData() method to obtain the row data for the selected row from the DataModel.

Note that because the DataModel is retaining context between page requests, it has to be in a View or Session-scope object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!