Reputation: 1178
I have a JSF page in which, I have created a html table and displaying the row data using ui:repeat. I have a save button where, when I select a particular row, I want the entire row data to be saved. When I try to select the particular row, Im unable to get the row data. ui:repeat does not have a binding attribute to bind it to the backing bean dataTable.
Can you please suggest how to acheive the same. Thanks in Advance
Upvotes: 0
Views: 1304
Reputation: 21993
Make sure to hookup the checkboxes to a bean property:
<h:selectBooleanCheckbox id="selection" value="#{listController.checked[item.id]}" />
In your bean you would need:
private Map<Integer, Boolean> checked = new HashMap<Integer, Boolean>();
public Map<Integer, Boolean> getChecked() {
return checked;
}
Then if you want to know which item(s) were selected you can do:
for (Map.Entry<Integer, Boolean> e : checked.entrySet()) {
if (e.getValue()) {
// do something with selected row
}
}
Upvotes: 1
Reputation: 2505
You can achieve this by passing the current row as parameter in an action that you must call on onchange
event of selectBooleanCheckbox
using jsf:ajax
.
Upvotes: 0