Changeset 96 for trunk/src/grails-app/controllers
- Timestamp:
- Mar 31, 2009, 5:43:09 AM (16 years ago)
- Location:
- trunk/src/grails-app/controllers
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/grails-app/controllers/TaskController.groovy
r85 r96 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 @Secured(['ROLE_AppAdmin']) 4 class TaskController extends BaseController { 3 class TaskController extends BaseAppAdminController { 5 4 6 5 def index = { redirect(action:list,params:params) } … … 10 9 11 10 def list = { 12 if(!params.max) params.max = 1013 [ taskInstanceList: Task.list( params ) ]11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 [ taskInstanceList: Task.list( params ), taskInstanceTotal: Task.count() ] 14 13 } 14 15 15 def show = { 16 16 def taskInstance = Task.get( params.id ) … … 22 22 else { return [ taskInstance : taskInstance ] } 23 23 } 24 24 25 25 def delete = { 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 { … … 51 57 def taskInstance = Task.get( params.id ) 52 58 if(taskInstance) { 59 if(params.version) { 60 def version = params.version.toLong() 61 if(taskInstance.version > version) { 62 63 taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 64 render(view:'edit',model:[taskInstance:taskInstance]) 65 return 66 } 67 } 53 68 taskInstance.properties = params 54 69 if(!taskInstance.hasErrors() && taskInstance.save()) { … … 82 97 } 83 98 } 84 85 99 } -
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.