Hi,
I'd like to have an edit button in front of each row of my list.
Even after googling a lot I can't find out to properly do it.
I am trying the following starting from the generated method but cannot find how to handle the version number (e.g. locking).
List view:
Controller:Code:<g:each in="${internalNoteInstanceList}" var="item"> <tr> <td> <a href="${createLink(controller:'internalNote',action:'update',id:''+item.id)}"> <g:img dir="images" file="edit.png" /> </a> </td>
Code:def update(Long id, Long version) { def internalNoteInstance = InternalNote.get(id) if (!internalNoteInstance) { flash.message = message(code: 'default.not.found.message', args: [message(code: 'internalNote.label', default: 'InternalNote'), id]) redirect(action: "list") return } if (version != null) { if (internalNoteInstance.version > version) { internalNoteInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: 'internalNote.label', default: 'InternalNote')] as Object[], "Another user has updated this InternalNote while you were editing") render(view: "edit", model: [internalNoteInstance: internalNoteInstance]) return } } internalNoteInstance.properties = params if (!internalNoteInstance.save(flush: true)) { render(view: "create", model: [internalNoteInstance: internalNoteInstance]) return } flash.message = message(code: 'default.updated.message', args: [message(code: 'internalNote.label', default: 'InternalNote'), internalNoteInstance.id]) redirect(action: "show", id: internalNoteInstance.id) }


Reply With Quote