Ignore:
Timestamp:
Dec 1, 2009, 1:48:20 AM (15 years ago)
Author:
gav
Message:

Refactor taskService update() and enable optimistic version checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r196 r204  
    408408        }
    409409        else {
    410             if(result.taskInstance) {
    411                 render(view:'edit',model:[taskInstance:result.taskInstance])
    412             }
    413             else {
    414                 flash.message = "Task could not be updated."
    415                 redirect(action: 'search')
    416             }
    417         }
    418 
    419     }
    420 
    421 //     def update = {
    422 //         def taskInstance = Task.get( params.id )
    423 //         if(taskInstance) {
    424 //             if(params.version) {
    425 //                 def version = params.version.toLong()
    426 //                 if(taskInstance.version > version) {
    427 //
    428 //                     taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.")
    429 //                     render(view:'edit',model:[taskInstance:taskInstance])
    430 //                     return
    431 //                 }
    432 //             }
    433 //             taskInstance.properties = params
    434 //             if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) {
    435 //                 flash.message = "Task ${params.id} updated"
    436 //                 redirect(action:show,id:taskInstance.id)
    437 //             }
    438 //             else {
    439 //                 render(view:'edit',model:[taskInstance:taskInstance])
    440 //             }
    441 //         }
    442 //         else {
    443 //             flash.message = "Task not found with id ${params.id}"
    444 //             redirect(action:edit,id:params.id)
    445 //         }
    446 //     }
     410            render(view:'edit',model:[taskInstance:result.taskInstance.refresh()])
     411        }
     412
     413    }
    447414
    448415    def create = {
Note: See TracChangeset for help on using the changeset viewer.