Grails WebFlow 状态名称
Grails 菜鸟在这里...
如何获取 Grails Webflow 状态中的状态名称?我正在使用 Grails WebFlow 和 jQueryMobile 制作移动应用程序的原型。因为它是一个主要由列表组成的移动应用程序,所以我使用如下所示的堆栈来管理后台事件:
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( ... )
}
}
}
这可行,但我想替换 flow.states <<; 等行中的硬编码状态名称字符串。如果有办法的话,使用表达式“state#”。
编辑:我会接受解释为什么不能这样做的答案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 RequestContext 和/或 FlowExecutionContext?例如 flowExecutionContext.currentState.id
Try using the RequestContext and/or the FlowExecutionContext? e.g. flowExecutionContext.currentState.id