I am displaying multiple records in a table on a form. The first column in each table is a checkbox that is used flag record(s) for deletion.
If a checkbox is checked, it returns the String value associated with the checkbox back to the form in a List<String>
. If no checkbox is checked, the List is set to null.
This works fine is there is no record, or if there are multiple records. But if there is one record, the value 'false' gets returned to the List<String>
instead of null when no checkbox is checked.
I have read where people have discussed setting the checkbox interceptor "uncheckedValue" to null, but I have not been able to successfully do this or find an example of how this is done. How is this done?
In my Action....
private List<String> idsToDelete;
public List<String> getIdsToDelete() {
return idsToDelete;
}
public void setIdsToDelete(List<String> idsToDelete) {
this.idsToDelete = idsToDelete;
}
In my JSP...
<s:iterator value="adjustmentData" status="rowStatus">
<tr>
<td>
<s:checkbox fieldValue="%{transactionId}"
name="idsToDelete"
class="deleteCheckbox">
</s:checkbox>
If there is no data, idsToDelete = null
If there are records and checkboxes checked, idsToDelete = [00200027, 00200028, etc]
If there are multiple records and no checkboxes checked, idsToDelete = null
If there is one record and checkbox not checked, idsToDelete = [false]