Ignore:
Timestamp:
Mar 22, 2010, 11:38:25 AM (10 years ago)
Author:
keesvb
Message:

debugged EventDescription?.save, added comment field for template fields, add code comments to setFieldValue, added missing events to PPSH demo in BootStrap?, cleaned up home menu, re-added searchable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/EventDescriptionController.groovy

    r289 r290  
    116116            description.name=params['name']
    117117
    118             // description.description=params['description']   // has to be a Term
     118            description.description=params['description']
    119119            // description.classification=params['classification']  // has to be a Term
    120120            description.isSamplingEvent= params['isSample']=='true'?true:false
     
    244244
    245245
    246         // make changes persitant
    247 
    248         if (description.save(flush: true)) {
    249             flash.message = "${message(code: 'default.created.message', args: [message(code: 'description.label', default: 'EventDescription'), description.id])}"
    250             redirect(action: "show", id: description.id)
    251         }
    252         else {
    253             render(view: "create", model: [description: description])
    254         }
    255 
    256         render( action: 'list' )
     246        // Check for errors in protocol, and if none, persist it
     247        protocol.validate()
     248        if (protocol.hasErrors()) {
     249                render "Errors during save of protool:\n"
     250                for (e in description.errors) {
     251                        render e
     252                }
     253        }
     254        else {
     255                protocol.save(flush:true)
     256        }
     257
     258
     259        // Important: add protocol to EventDescription
     260        description.protocol = protocol
     261
     262
     263        // Check for errors in EventDescription, if no errors, persist the data
     264        description.validate()
     265        if (description.hasErrors()) {
     266                render "Errors during save of event description:\n"
     267                for (e in description.errors) {
     268                        render e
     269                }
     270        }
     271        else {
     272                if (description.save(flush: true)) {
     273                        flash.message = "${message(code: 'default.created.message', args: [message(code: 'description.label', default: 'EventDescription'), description.id])}"
     274                    redirect(view: "show", id: description.id)
     275
     276                }
     277                else {
     278                    redirect(view: "create", model: [description: description])
     279                }
     280        }
     281
    257282    }
    258283
     
    264289        if (!eventDescriptionInstance) {
    265290            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'eventDescription.label', default: 'EventDescription'), params.id])}"
    266             redirect(action: "list")
     291            redirect(view: "list")
    267292        }
    268293
    269294        else {
    270295            [eventDescriptionInstance: eventDescriptionInstance, params:params]
     296            // Since show.gsp is not implemented yet, redirect to edit
     297            redirect(action:'edit',id:params.id)
    271298        }
    272299    }
Note: See TracChangeset for help on using the changeset viewer.