Wrap the collection behind datatable value's DataModel<E>.
private List<Item> items;
private DataModel<Item> model;
@PostConstruct
public void init() {
this.items = loadItSomehow();
this.model = new ListDataModel<Item>(items);
}
( Itemin this example, this is just the javabean class representing each row, for example Person, Productetc.)
Instead, bind it to a datatable value.
<h:dataTable value="#{bean.model}" var="item">
If the drop-down menu is tied to a property Item, and the button is tied to a method of the same bean ...
<h:column>
<h:selectOneMenu value="#{item.value}">
<f:selectItems value="#{bean.values}" />
</h:selectOneMenu>
</h:column>
<h:column>
<h:commandButton value="submit" action="#{bean.submit}" />
</h:column>
... DataModel#getRowData() :
public void submit() {
Item item = model.getRowData();
String value = item.getValue();
}