Changeset 482 for trunk/grails-app/controllers
- Timestamp:
- Apr 13, 2010, 11:02:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/EntryDetailedController.groovy
r394 r482 93 93 94 94 def create = { 95 try { 96 def taskInstance = Task.get(params.taskInstance.id) 97 def entryInstance = new Entry() 98 entryInstance.task = taskInstance 99 entryInstance.entryType = EntryType.get(params.entryType.id) 100 return ['entryInstance':entryInstance] 95 if(!params.taskInstance?.id || !params.entryType?.id) { 96 flash.message = g.message(code:"entry.create.no.params") 97 redirect(controller:"taskDetailed", action:"search") 98 return 101 99 } 102 catch(Exception e) { 103 flash.message = "Please select a task, then 'Add Entry'." 100 101 def taskInstance = Task.read(params.taskInstance.id) 102 103 if(!taskInstance) { 104 flash.message = g.message(code:"task.notFound") 104 105 redirect(controller:"taskDetailed", action:"search") 106 return 105 107 } 106 } 108 109 // Check for Complete task. 110 if(taskInstance.taskStatus.id == 3) { 111 flash.errorMessage = g.message(code:"task.operationNotPermittedOnCompleteTask") 112 redirect(controller:"taskDetailed", action:"show", id: taskInstance.id) 113 return 114 } 115 116 def entryInstance = new Entry() 117 entryInstance.task = taskInstance 118 entryInstance.entryType = EntryType.read(params.entryType.id) 119 return ['entryInstance': entryInstance] 120 } // create 107 121 108 122 def save = { … … 112 126 flash.message = "Entry created." 113 127 redirect(controller: "taskDetailed", action: "show", id: result.taskId) 128 return 114 129 } 115 else {116 if(result.entryInstance) {117 render(view:'create',model:[entryInstance: result.entryInstance])118 }119 else {120 flash.message = "Could not create entry."121 redirect(controller: "taskDetailed", action:"search")122 }123 130 131 if(result.error.code != "default.create.failure") { 132 params.errorMessage = g.message(code: result.error.code) 124 133 } 125 }126 134 127 } 135 render(view:'create',model:[entryInstance: result.entryInstance]) 136 } // save 137 138 } // end class
Note: See TracChangeset
for help on using the changeset viewer.