Changeset 373 for trunk/grails-app/controllers
- Timestamp:
- Apr 22, 2010, 5:07:09 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/TemplateEditorController.groovy
r372 r373 38 38 def pagesFlow = { 39 39 // start the flow 40 onStart { 41 println params 42 if (params.entity) { 43 //def name = params.entity 44 //def name = "java.lang.Integer" 45 //println name.class 46 //def S = new dbnp.studycapturing.Study() 40 start { 41 action { 42 // define initial flow variables 43 flow.entity = null 44 flow.templates = [] 47 45 48 //def name = "dbnp.studycapturing.Study" as Class 49 //println name.newInstance() 50 println Class.forName(new GString("dbnp.studycapturing.Study")) 51 //flow.entity = (name as Class).newInstance() 52 //flow.templates = Template.findAllByEntity(flow.entity) 53 } else { 54 // all templates for all entities; note that normally 55 // this shouldn't happen as this flow is designed to 56 // launch in a jquery dialog, passing an encoded entity 57 flow.templates = Template.findAll() 46 // define success variable 47 def errors = true 48 49 // got an entity parameter? 50 if (params.entity && params.entity instanceof String) { 51 // yes, try to dynamicall load the entity 52 try { 53 // dynamically load the entity 54 def entity = Class.forName(params.entity, true, this.getClass().getClassLoader()) 55 56 // succes, is entity an instance of TemplateEntity? 57 if (entity.superclass =~ /TemplateEntity$/) { 58 errors = false 59 60 // yes, assign entity to the flow 61 flow.entity = entity 62 63 // fetch all templates to this entity 64 flow.templates = Template.findAllByEntity(entity) 65 } 66 } catch (Exception e) { } 67 } 68 69 // success? 70 if (errors) { 71 error() 72 } else { 73 success() 74 } 58 75 } 59 flow.templates = Template.findAll() 76 on("success").to "templates" 77 on("error").to "errorInvalidEntity" 78 } 79 80 // error dynamically loading entity 81 errorInvalidEntity { 82 render(view: "_errorInvalidEntity") 60 83 } 61 84
Note: See TracChangeset
for help on using the changeset viewer.