I've removed some of the markup for brevity and to bring focus to the important bits. This is one way of doing it without relying on Javascript and what do you know, it is pure grails. Never say never, @rmlan.
<g:form action="updateSold" controller="book">
<table>
<tbody>
<g:each in="${bookInstanceList}" status="i" var="bookInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:link action="show" id="${bookInstance.id}">${fieldValue(bean: bookInstance, field: "title")}</g:link></td>
<td>
<g:checkBox name="sold" value="${bookInstance.sold}" />
<g:hiddenField name="id" value="${bookInstance.id}" />
</td>
</tr>
</g:each>
</tbody>
</table>
<g:submitButton name="updateSold" value="Update" />
</g:form>
This is the controller action:
def updateSold() {
def solds = params.list('sold')
def ids = params.list('id')
ids.eachWithIndex { id, idx ->
if (solds[idx]) {
// the book's sold has been checked, so update it to TRUE
} else {
// the books sold has not been checked, so update it to FALSE
}
}
}