root/trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy @ 88

Revision 88, 2.2 KB (checked in by duh, 4 years ago)

- refactored the wizard code a bit

  • Property svn:keywords set to Rev Author Date
Line 
1package dbnp.studycapturing
2import dbnp.studycapturing.*
3import grails.converters.*
4
5/**
6 * Wizard Controler
7 *
8 * The wizard controller handles the handeling of pages and data flow
9 * through the study capturing wizard.
10 *
11 * @author  Jeroen Wesbeek
12 * @since   20100107
13 * @package studycapturing
14 *
15 * Revision information:
16 * $Rev$
17 * $Author$
18 * $Date$
19 */
20class WizardController {
21    /**
22     * index method, redirect to the webflow
23     * @void
24     */
25    def index = {
26      /**
27       * Do you believe it in your head?
28       * I can go with the flow
29       * Don't say it doesn't matter (with the flow) matter anymore
30       * I can go with the flow (I can go)
31       * Do you believe it in your head?
32       */
33      redirect(action:'pages')
34    }
35
36    /**
37     * WebFlow definition
38     * @see http://grails.org/WebFlow
39     * @void
40     */
41    def pagesFlow = {
42      // start the flow
43      onStart {
44        println "wizard started"
45       
46        // define flow variables
47        flow.page = 0
48        flow.pages = [
49                [title:'Een'],
50                [title:'Twoooo'],
51                [title:'Trois']
52        ]
53       
54      }
55      onEnd {
56            println "wizard ended"
57          }
58
59          // render the main wizard page
60          mainPage {
61            onRender {
62                  println "render main page"
63          flow.page = 1
64            }
65            render(view:"/wizard/index")
66        on("next") {
67          println "next page!"
68        }.to "pageTwo"
69      }
70
71      pageOne {
72            onRender {
73                  println "render page one"
74          flow.page = 1
75            }
76            render(view:"_one")
77        on("next") {
78          println "next page!"
79        }.to "pageTwo"
80      }
81
82          // render page two
83          pageTwo {
84            onRender {
85                  println "render page two"
86          flow.page = 2
87            }
88        render(view:"_two")
89        on("next") {
90          println "next page!"
91        }.to "pageThree"
92        on("previous") {
93          println "previous page!"
94        }.to "pageOne"
95          }
96
97          // render page three
98          pageThree {
99            onRender {
100                  println "render page three"
101          flow.page = 3
102            }
103        render(view:"_three")
104        on("previous") {
105          println "previous page!"
106        }.to "pageTwo"
107          }
108    }
109}
Note: See TracBrowser for help on using the browser.