Redirect from a controller to another controller

richard orama

New member
After deleting a record in a controller, I want to redirect to the edit action of another controller as below. Unfortunately, it always takes me to the list action of the controller. What should I do? Sample below.


Code:
    def delete() {
       				def patientTBDrugInstance = PatientTBDrug.get(params.id)
        if (!patientTBDrugInstance) {
			flash.message = message(code: 'default.not.found.message', args: [message(code: 'patientTBDrug.label', default: 'PatientTBDrug'), params.id])
            //redirect(action: "list")
						redirect(controller: "specimen", action: "edit", id: params.specimen.id)
            return
        }

        try {
            patientTBDrugInstance.delete(flush: true)
			flash.message = message(code: 'default.deleted.message', args: [message(code: 'patientTBDrug.label', default: 'PatientTBDrug'), params.id])
            //redirect(action: "list")
						redirect(controller: "specimen", action: "edit", id: params.specimen.id)
        }
        catch (DataIntegrityViolationException e) {
			flash.message = message(code: 'default.not.deleted.message', args: [message(code: 'patientTBDrug.label', default: 'PatientTBDrug'), params.id])
            //redirect(action: "show", id: params.id)
						redirect(controller: "specimen", action: "edit", id: params.specimen.id)
        }
    }
 
Top