source: trunk/grails-app/controllers/SandboxController.groovy @ 162

Last change on this file since 162 was 162, checked in by duh, 13 years ago
  • set keyword expansion
  • Property svn:keywords set to
    Date
    Author
    Rev
File size: 866 bytes
RevLine 
[146]1import dbnp.studycapturing.*
[144]2
3// The sandbox is meant for internal communication over code examples etc.
4
5class SandboxController {
6
[146]7        def index = {
[144]8
[146]9                // Get the example study in a lazy way
10                def st = Study.get(1)
11                def f = st.template.subjectFields
[144]12
[146]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                }
[144]20
[146]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]
[144]29}
[146]30}
Note: See TracBrowser for help on using the repository browser.