Ignore:
Timestamp:
Mar 31, 2009, 5:43:09 AM (11 years ago)
Author:
gav
Message:

Implemented the bulk of AssignedPerson? domain

File:
1 edited

Legend:

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

    r85 r96  
    99
    1010    def list = {
    11         if(!params.max) params.max = 10
    12         [ taskInstanceList: Task.list( params ) ]
     11        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
     12        [ taskInstanceList: Task.list( params ), taskInstanceTotal: Task.count() ]
    1313    }
    1414
     
    2626        def taskInstance = Task.get( params.id )
    2727        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            }
    3137        }
    3238        else {
     
    5763        def taskInstance = Task.get( params.id )
    5864        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            }
    5974            taskInstance.properties = params
    6075            if(!taskInstance.hasErrors() && taskInstance.save()) {
Note: See TracChangeset for help on using the changeset viewer.