如何在grails web flow插件中获取当前视图状态名称,我正在尝试遵循此post但我无法让它在我的应用程序中工作我收到此错误消息
No such property: flowExecution for class: ni.org.petApp.AppController
感谢您的时间
答案 0 :(得分:1)
使用Grails 2.2.4或2.3.8以及grails-webflow插件版本2.0.8.1,我能够通过requestContext
访问当前的WebFlow状态:
RequestContext requestContext = RequestContextHolder.getRequestContext();
String stateId = requestContext.currentState.id
在WebFlow中使用这些方法时,您的控制器应如下所示:
package webflow.requestcontext
import org.springframework.webflow.execution.RequestContext
import org.springframework.webflow.execution.RequestContextHolder
class TestController {
def indexFlow = {
randomNameForStartState {
action {
RequestContext requestContext = RequestContextHolder.getRequestContext();
flow.startStateName = requestContext.currentState.id
}
on("success").to "showStartStateName"
}
showStartStateName() {
}
}
}
然后,您可以通过showStartStateName.gsp
${startStateName}
中打印开始状态
根据requestContext
,您还可以解析FlowExecutionContext
:
FlowExecutionContext flowExecutionContext = requestContext?.getFlowExecutionContext();