Changeset 146 for trunk/grails-app/controllers/SandboxController.groovy
- Timestamp:
- Jan 28, 2010, 6:42:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/SandboxController.groovy
r144 r146 1 import dbnp.studycapturing. Study1 import dbnp.studycapturing.* 2 2 3 3 // The sandbox is meant for internal communication over code examples etc. … … 5 5 class SandboxController { 6 6 7 7 def index = { 8 8 9 // Get the example study in a lazy way10 def st = Study.get(1)11 def f = st.template.subjectFields9 // Get the example study in a lazy way 10 def st = Study.get(1) 11 def f = st.template.subjectFields 12 12 13 // This is a way to iterate over the fields in your controller 14 // And print them to the console 15 // Most of the time, you would just iterate over them in the view using <g:each> 16 // See also views/sandbox/index.gsp 17 f.each{ field -> 18 println field.name} 13 // This is a way to iterate over the fields in your controller 14 // And print them to the console 15 // Most of the time, you would just iterate over them in the view using <g:each> 16 // See also views/sandbox/index.gsp 17 f.each {field -> 18 println field.name + "(" + field.type + ")" 19 } 19 20 20 // Specify which variables we want to be available in the controller (implicit return statement) 21 [fields : f] 22 } 21 //Let's get a certain field for a certain subject 22 def subject = Subject.findByName('A1') 23 println st.template.getSubjectFieldType('Age') 24 println subject.getFieldValue('Age') 25 26 27 // Specify which variables we want to be available in the controller (implicit return statement) 28 [fields: f, subjects: st.subjects] 23 29 } 30 }
Note: See TracChangeset
for help on using the changeset viewer.