开发者

Grails WebFlow State Name

Grails noob here...

How do I get the state name inside a Grails webflow state? I'm prototyping a mobile app using Grails WebFlow and jQueryMobile. Because it's a mobile app comprised primarily of lists, I manage the back events using a stack like this:

class myController {
    def myFlow {
        start {
            action {
                flow.states = []
                [ ... ]
            } 
            on("success").to "state0"
        }

        state0 {
            on("back").to "home"
            on("event") {
                flow.states << "state0"
            }.to "state1"
        }

        state1 {
            on("back").to { flow.states.pop() }
            on("event") {
                flow.states << "state1"
            }.to "state2"
        }

        state2 {
            on("back").to { flow.states.pop() }
   开发者_StackOverflow社区     }

        home {
            redirect( ... )
        }
    }
}

This works, but I'd like to replace the hard coded state name strings in lines like flow.states << "state#" with an expression if there's a way to do it.

EDIT: I'll accept answers that explain why this can't be done.


Try using the RequestContext and/or the FlowExecutionContext? e.g. flowExecutionContext.currentState.id

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜