processing a jsf datatable
I've a page with a datatable which can be considered a view on a table of a database. Some fields are static, but some others are inputText, which are meant to modify that field (in particular, all 开发者_如何学Cthe fields of a specific column).
I would like to press a button and save the whole table.
In general, I'd like to understand how to read an entire table in a managed bean.
Thanks!
EDIT:
I'll try to be more clear: imagine you've a NxM table of only inputText. Outside the table, a button with an action like #{SomeBean.process}. I'd like to have, in that process method, a List with length N and Row is an object with M fields.
If I understand correctly I think, you need to save not a datatable, you need to save a rows from this table. With JSF you can use binding and when you need to save data, you just get rows from this binding and make data operations.
If you used some kind of object-relatational mapping like JPA it would be quite easy. Then you could create an entity class of your database table and fill your datatable with a list of your entity objects.
Then you could submit the whole datatable and merge all the changes with your database.
Some IDEs like Netbeans even create entity classes automatically with the help of a wizard. If you are on Netbeans, I recommend to read the JSF Crud tutorial. For Eclipse there should be similiar tutorials, but I am not so familiar with this IDE.
精彩评论