- Timestamp:
- Mar 31, 2009, 5:43:09 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/grails-app/controllers/TaskDetailedController.groovy
r85 r96 9 9 10 10 def list = { 11 if(!params.max) params.max = 1012 [ taskInstanceList: Task.list( params ) ]11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 [ taskInstanceList: Task.list( params ), taskInstanceTotal: Task.count() ] 13 13 } 14 14 … … 26 26 def taskInstance = Task.get( params.id ) 27 27 if(taskInstance) { 28 taskInstance.delete() 29 flash.message = "Task ${params.id} deleted" 30 redirect(action:list) 28 try { 29 taskInstance.delete() 30 flash.message = "Task ${params.id} deleted" 31 redirect(action:list) 32 } 33 catch(org.springframework.dao.DataIntegrityViolationException e) { 34 flash.message = "Task ${params.id} could not be deleted" 35 redirect(action:show,id:params.id) 36 } 31 37 } 32 38 else { … … 57 63 def taskInstance = Task.get( params.id ) 58 64 if(taskInstance) { 65 if(params.version) { 66 def version = params.version.toLong() 67 if(taskInstance.version > version) { 68 69 taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 70 render(view:'edit',model:[taskInstance:taskInstance]) 71 return 72 } 73 } 59 74 taskInstance.properties = params 60 75 if(!taskInstance.hasErrors() && taskInstance.save()) {
Note: See TracChangeset
for help on using the changeset viewer.