1
votes

I started using Grails web flow in order to implement a wizard.

checkStep {

        action {
            User user = springSecurityService.currentUser
            if (springSecurityService.loggedIn){
                def next = wizardService.getNextFlowStep(user)
                switch (next) {
                       case step1: 
                              step1()
                              break
    ...
                 }
         }
         on("step1").to "wizard_step1"
  } // checkStep
 wizard_step1() {
  ...
 }

I'd like to write the first step in more elegant way, such that based on "wizardService" the next step will be determined. I also preferred that the steps will be determined at run time, such that the actual step names and order may be reside in a database.

THanks

1

1 Answers

0
votes

You want to use groovy's dynamic method invocation for something like this. I'm not sure if this will actually work inside of a webflow but it should look something like this....

        def next = wizardService.getNextFlowStep(user); // returns 'step1';
        "${next}"(); // you may have to use 'this."${next}"();'