Index: trunk/grails-app/controllers/TaskDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 203)
+++ trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 204)
@@ -408,41 +408,8 @@
         }
         else {
-            if(result.taskInstance) {
-                render(view:'edit',model:[taskInstance:result.taskInstance])
-            }
-            else {
-                flash.message = "Task could not be updated."
-                redirect(action: 'search')
-            }
-        }
-
-    }
-
-//     def update = {
-//         def taskInstance = Task.get( params.id )
-//         if(taskInstance) {
-//             if(params.version) {
-//                 def version = params.version.toLong()
-//                 if(taskInstance.version > version) {
-// 
-//                     taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.")
-//                     render(view:'edit',model:[taskInstance:taskInstance])
-//                     return
-//                 }
-//             }
-//             taskInstance.properties = params
-//             if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) {
-//                 flash.message = "Task ${params.id} updated"
-//                 redirect(action:show,id:taskInstance.id)
-//             }
-//             else {
-//                 render(view:'edit',model:[taskInstance:taskInstance])
-//             }
-//         }
-//         else {
-//             flash.message = "Task not found with id ${params.id}"
-//             redirect(action:edit,id:params.id)
-//         }
-//     }
+            render(view:'edit',model:[taskInstance:result.taskInstance.refresh()])
+        }
+
+    }
 
     def create = {
Index: trunk/grails-app/i18n/messages.properties
===================================================================
--- trunk/grails-app/i18n/messages.properties	(revision 203)
+++ trunk/grails-app/i18n/messages.properties	(revision 204)
@@ -76,4 +76,5 @@
 default.paginate.prev=Previous
 default.paginate.next=Next
+default.optimistic.locking.failure=Another user has updated this item while you were editing.
 
 # Rich UI plugin - Calendar
Index: trunk/grails-app/services/TaskService.groovy
===================================================================
--- trunk/grails-app/services/TaskService.groovy	(revision 203)
+++ trunk/grails-app/services/TaskService.groovy	(revision 204)
@@ -172,5 +172,5 @@
                 }
 
-                // All went well if we get to here.
+                // If we get here all went well.
                 return result
             }
@@ -186,44 +186,42 @@
     * Updates an existing task.
     * @param params The params to update for task with id of params.id.
-    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance (if available).
     */
     def update(params) {
         Task.withTransaction { status ->
             def result = [:]
-            result.taskInstance = Task.get(params.id)
-            if(result.taskInstance) {
-
-                // Optimistic locking check.
-                if(params.version) {
-                    def version = params.version.toLong()
-                    if(result.taskInstance.version > version) {
-                        status.setRollbackOnly()
-                        result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.")
-                        result.error = true
-                        return result
-                    }
-                }
-
-                result.taskInstance.properties = params
-
-                if(result.taskInstance.save()) {
-                    def taskModification = new TaskModification(person:personService.currentUser(),
-                                                            taskModificationType: TaskModificationType.get(3),
-                                                            task: result.taskInstance)
-                    if(taskModification.save()) {
-                        // All went well.
-                        return result
-                    }
-                    else {
-                        status.setRollbackOnly()
-                        result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave")
-                        result.error = true
-                        return result
-                    }
-                }
-            }
-            // Something failed.
-            status.setRollbackOnly()
-            result.error = true
+
+            def fail = { Object[] args ->
+                status.setRollbackOnly()
+                if(args.size() == 2) result.taskInstance.errors.rejectValue(args[0], args[1])
+                result.error = true
+                return result
+            }
+
+            result.taskInstance = Task.get(params.id)
+
+            if(!result.taskInstance)
+                return fail('task', "task.notFound")
+
+            // Optimistic locking check.
+            if(params.version) {
+                def version = params.version.toLong()
+                if(result.taskInstance.version > version)
+                    return fail("version", "default.optimistic.locking.failure")
+            }
+
+            result.taskInstance.properties = params
+
+            if(result.taskInstance.hasErrors() || !result.taskInstance.save())
+                return fail()
+
+            def taskModification = new TaskModification(person:personService.currentUser(),
+                                                    taskModificationType: TaskModificationType.get(3),
+                                                    task: result.taskInstance)
+
+            if(!taskModification.save())
+                return fail("taskModifications", "task.modifications.failedToSave")
+
+            // If we get here all went well.
             return result
 
Index: trunk/grails-app/views/taskDetailed/edit.gsp
===================================================================
--- trunk/grails-app/views/taskDetailed/edit.gsp	(revision 203)
+++ trunk/grails-app/views/taskDetailed/edit.gsp	(revision 204)
@@ -24,4 +24,5 @@
             <g:form method="post" >
                 <input type="hidden" name="id" value="${taskInstance?.id}" />
+                <input type="hidden" name="version" value="${taskInstance?.version}" />
                 <div class="dialog">
                     <table>
