posted 11 years ago
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.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.