【问题标题】:Spring webflow 2.3.0 - How to get flowExecutionKey in form action method?Spring webflow 2.3.0 - 如何在表单操作方法中获取 flowExecutionKey?
【发布时间】:2012-07-28 14:08:16
【问题描述】:

我在表单操作类中有一些代码需要从RequestContext 获取flowExecutionKey。我似乎找不到任何有关如何执行此操作的文档。我的班级看起来像这样:

public class MyFormAction extends FormAction
{
    public Event doStuff(RequestContext context)
    {
        String flowExecutionKey = ...??
        ...
    }
}

我知道我真的不需要获取 flowExecutionKey,但我正在处理一些需要它的遗留代码。此方法被称为视图状态的入口操作。我试过context.getFlowExecutionContext().getKey(),但它返回null。 context.getFlowExecutionUrl() 也返回 null。有没有办法做到这一点?

更新

我又在玩这个,context.getFlowExecutionContext().getKey()<on-render> 而不是<on-entry> 中调用该方法时确实获得了flowExecutionKey。还值得注意的是,它在<on-entry> 期间以稍后的视图状态工作。它不工作的视图状态是我流程中的第一个视图状态。是否有某些原因我无法在第一个视图状态下获得 <on-entry> 中的 flowExecutionKey?

【问题讨论】:

    标签: spring spring-webflow


    【解决方案1】:

    <on-entry> 回调在初始 POST 到服务器期间执行。这将有一个类似http://server/myflow 的 URL。完成后,webflow 将重定向到http://server/myflow?execution=e1s1。正是在此调用期间,<on-render> 执行。

    所以,您没有在初始<on-render 中获得密钥的原因是尚未分配密钥。而您在后面的<on-render>s 中看到的键实际上是 previous 视图的键。

    也看一下RequestContext.getFlowExecutionUrl() - 它会告诉您当前请求的 URL。这应该会有所启发。

    【讨论】:

      猜你喜欢
      • 2014-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-08
      • 2011-07-25
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多