- Timestamp:
- Mar 13, 2011, 12:05:16 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/EntryDetailedController.groovy
r838 r859 10 10 11 11 // the delete, save and update actions only accept POST requests 12 static allowedMethods = [delete:'POST', save:'POST', update:'POST' ]12 static allowedMethods = [delete:'POST', save:'POST', update:'POST', ajaxCreate:'POST', ajaxSave:'POST'] 13 13 14 14 def list = { … … 106 106 def ajaxCreate = { 107 107 if(!params.taskId || !params.entryTypeId) { 108 response.status = 403109 108 params.errorMessage = g.message(code: "entry.create.no.params.ajax") 110 render( template: "/shared/messages")109 render(contentType:"text/json", status: 403, template: "/shared/messages") 111 110 return 112 111 } … … 115 114 116 115 if(!taskInstance) { 117 response.status = 403118 116 params.errorMessage = g.message(code:"default.not.found", args:['Task',params.taskId]) 119 render( template: "/shared/messages")117 render(contentType:"text/json", status: 403, template: "/shared/messages") 120 118 return 121 119 } … … 123 121 // Check for Complete task. 124 122 if(taskInstance.taskStatus.id == 3) { 125 response.status = 403126 123 params.errorMessage = g.message(code:"task.operationNotPermittedOnCompleteTask") 127 render( template: "/shared/messages")124 render(contentType:"text/json", status: 403, template: "/shared/messages") 128 125 return 129 126 } … … 133 130 entryInstance.task = taskInstance 134 131 entryInstance.entryType = EntryType.read(params.entryTypeId) 135 render(template: "create", model: ['entryInstance': entryInstance]) 136 } 132 def model = ['entryInstance': entryInstance] 133 134 render(contentType:"text/json") { 135 updates = array { 136 element([ mode: 'replace', target:"$params.target", content: g.render(template: 'create', model:model) ]) 137 } 138 } 139 140 } // ajaxCreate 137 141 138 142 def ajaxSave = { … … 142 146 if(!result.error) { 143 147 def entryList = Entry.withCriteria { 144 eq("entryType", result.entryInstance.entryType) 145 task { 146 idEq(result.taskId) 147 } 148 } 149 render(template: "list", model: ['entryList': entryList]) 150 return 151 } 152 153 if(result.error.code != "default.create.failure") { 154 response.status = 403 148 eq("entryType", result.entryInstance.entryType) 149 task { 150 idEq(result.taskId) 151 } 152 } 153 154 def model = ['entryList': entryList] 155 156 render(contentType:"text/json") { 157 updates = array { 158 element([ mode: 'replace', target:"$params.target", content: g.render(template: 'list', model:model) ]) 159 } 160 } 161 return 162 } 163 164 if(result.error.code != "default.create.failure") 155 165 params.errorMessage = g.message(code: result.error.code) 156 render(template: "/shared/messages") 157 return 158 } 159 160 response.status = 403 161 render(template: "create", model: ['entryInstance': result.entryInstance]) 166 167 def model = ['entryInstance': result.entryInstance] 168 render(contentType:"text/json", status: 403, template: "create", model: model) 162 169 } // ajaxSave 163 170
Note: See TracChangeset
for help on using the changeset viewer.