2011-01-21 41 views
2

Grails noob here ...Grails WebFlow状态名称

如何在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#"与表达如果有办法做到这一点。

编辑:我会接受解释为什么不能这样做的答案。

+0

您是否尝试过使用RequestContext和/或FlowExecutionContext?例如flowExecutionContext.currentState.id? – callie16

+0

呼叫良好。我发现这个代码工作:'flow.states << flowExecution.activeSession.state.id'。如果你想将此作为回应而不是评论,我肯定会接受它。 – lambmj

+0

谢谢,会做;) – callie16

回答

2

尝试使用RequestContext和/或FlowExecutionContext?例如flowExecutionContext.currentState.id