I have a datatable where the rows are dynamic and each row contain a selectOneMenu. If I have a button on each row and I want to get the selected item on the selectOneMenu, what’s the best way to do it?
I have a datatable where the rows are dynamic and each row contain a
Share
Wrap the collection behind datatable’s
valuein aDataModel<E>.(the
Itemin this example is just the javabean class representing every row, e.g.Person,Product, etc)Bind it to the datatable’s
valueinstead.If the dropdown is bound to a property of
Itemand the button to a method of the same bean …… then you can grab the current item by
DataModel#getRowData()and corrspondingly also the selected value in action method as follows: