Ignore:
Timestamp:
Oct 25, 2010, 4:23:39 PM (6 years ago)
Author:
robert@…
Message:

Fixed bug #15

File:
1 edited

Legend:

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

    r959 r987  
    4848    static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
    4949
     50        /**
     51     * Fires after every action and determines the layout of the page
     52     */
     53    def afterInterceptor = { model, modelAndView ->
     54      println( params );
     55
     56      if ( params['dialog'] ) {
     57        model.layout = 'dialog';
     58        model.extraparams = [ 'dialog': 'true' ] ;
     59      } else {
     60        model.layout = 'main';
     61        model.extraparams = [] ;
     62      }
     63    }
     64
    5065    def index = {
    5166        redirect(action: "list", params: params)
     
    6580    def save = {
    6681        def personAffiliationInstance = new PersonAffiliation(params)
     82        def extraparams = new LinkedHashMap();
     83
     84        if( params[ 'dialog' ] ) {
     85          extraparams[ 'dialog' ] = params[ 'dialog' ]
     86        }
     87
    6788        if (personAffiliationInstance.save(flush: true)) {
    6889            flash.message = "${message(code: 'default.created.message', args: [message(code: 'personAffiliation.label', default: 'Affiliation'), personAffiliationInstance])}"
    69             redirect(action: "show", id: personAffiliationInstance.id)
     90            redirect(action: "show", id: personAffiliationInstance.id, params: extraparams)
    7091        }
    7192        else {
     
    98119    def update = {
    99120        def personAffiliationInstance = PersonAffiliation.get(params.id)
     121
     122        def extraparams = new LinkedHashMap();
     123
     124        if( params[ 'dialog' ] ) {
     125          extraparams[ 'dialog' ] = params[ 'dialog' ]
     126        }
     127
    100128        if (personAffiliationInstance) {
    101129            if (params.version) {
     
    111139            if (!personAffiliationInstance.hasErrors() && personAffiliationInstance.save(flush: true)) {
    112140                flash.message = "${message(code: 'default.updated.message', args: [message(code: 'personAffiliation.label', default: 'Affiliation'), personAffiliationInstance])}"
    113                 redirect(action: "show", id: personAffiliationInstance.id)
     141                redirect(action: "show", id: personAffiliationInstance.id, params: extraparams)
    114142            }
    115143            else {
     
    119147        else {
    120148            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'personAffiliation.label', default: 'Affiliation'), params.id])}"
    121             redirect(action: "list")
     149            redirect(action: "list", params: extraparams)
    122150        }
    123151    }
     
    125153    def delete = {
    126154        def personAffiliationInstance = PersonAffiliation.get(params.id)
     155
     156        def extraparams = new LinkedHashMap();
     157
     158        if( params[ 'dialog' ] ) {
     159          extraparams[ 'dialog' ] = params[ 'dialog' ]
     160        }
     161
    127162        if (personAffiliationInstance) {
    128163            def affiliationName = personAffiliationInstance.toString()
     
    130165                personAffiliationInstance.delete(flush: true)
    131166                flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'personAffiliation.label', default: 'Affiliation'), affiliationName])}"
    132                 redirect(action: "list")
     167                redirect(action: "list", params: extraparams)
    133168            }
    134169            catch (org.springframework.dao.DataIntegrityViolationException e) {
    135170                flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'personAffiliation.label', default: 'Affiliation'), affiliationName])}"
    136                 redirect(action: "show", id: params.id)
     171                redirect(action: "show", id: params.id, params: extraparams)
    137172            }
    138173        }
    139174        else {
    140175            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'personAffiliation.label', default: 'Affiliation'), params.id])}"
    141             redirect(action: "list")
     176            redirect(action: "list", params: extraparams)
    142177        }
    143178    }
Note: See TracChangeset for help on using the changeset viewer.