Grails WebFlow状态名称 [英] Grails WebFlow State Name
问题描述
Grails noob here ...
如何在Grails webflow状态中获取状态名称?我正在使用Grails WebFlow和jQueryMobile构建移动应用程序原型。因为它是一个主要由列表组成的移动应用程序,所以我使用这样的堆栈管理后台事件:
class myController {
def myFlow {
start {
action {
flow.states = []
[...]
}
on(success )tostate0
}
state0 {
on(back)。tohome
on(event){
flow.states<< state0
} .tostate1
}
state1 {
on(back)。to {flow.states.pop()}
on(event){
flow.states<< state1
} .tostate2
}
state2 {
on(back)。to {flow.states.pop()}
$ b $ home
redirect(...)
}
}
}
这可行,但我想用行替换硬编码的状态名称字符串,如 flow.states<< 状态#
如果有办法做到这一点,就用一个表达式。
编辑:我会接受解释为什么可以'
尝试使用RequestContext和/或FlowExecutionContext?例如flowExecutionContext.currentState.id
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.
Try using the RequestContext and/or the FlowExecutionContext? e.g. flowExecutionContext.currentState.id
这篇关于Grails WebFlow状态名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!