Grails WebFlow State Name

牧云@^-^@ 提交于 2019-12-02 03:54:55

问题


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() }
        }

        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.


回答1:


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



来源:https://stackoverflow.com/questions/4763511/grails-webflow-state-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!