0

我有一个带有两个 webflow 的 Grails 应用程序:

  1. 一个用于采购
  2. 另一个与我们联系

问题:

用户可能会在购买向导中执行多个步骤(通过网络流),然后他/她决定他们有问题并尝试与我们联系(也通过网络流)。因此,用户点击了我们导航菜单上的“联系我们”链接,但他们又回到了购买流程中的最后一步。我个人认为这与会话中的“执行”键有关,每个链接都以 ie 为后缀

...../contact_us/index?execution=e1s1

我想要的解决方案:

我想(在上述情况下),如果用户决定自己从“购买流程”切换到“联系我们的流程”,那么“购买流程”会失效/删除,并且用户从头开始在“联系我们的流程'。

Grails 2.2.3 版 Webflow 插件:2.0.8.1

尝试的解决方案

我能想出的最好的解决方案(不做太难看的事情)是创建一个过滤器,当一个链接被点击以开始一个新的流程并尝试删除另一个时,它会拦截。但是,在此示例中,它令人惊讶地未能在流存储库(空指针)中找到流。

FlowExecutionLock flowExecutionLock = null;
SessionBindingConversationManager conversationManager = applicationContext.getBean('conversationManager');
DefaultFlowExecutionRepository flowExecutionRepository = applicationContext.getBean("flowExecutionRepository");
try {
    String executionKey = params.get("execution");// executionKey is something like 'e1s1'
    FlowExecutionKey flowExecutionKey = flowExecutionRepository.parseFlowExecutionKey(executionKey);
    flowExecutionLock = flowExecutionRepository.getLock(flowExecutionKey);
    flowExecutionLock.lock();
    FlowExecution execution = flowExecutionRepository.getFlowExecution(flowExecutionKey);
    flowExecutionRepository.removeFlowExecution(execution);
} catch (FlowExecutionRepositoryException e) {
    log.warn("Could not find flow in repository with id ${executionKey} " + e.getMessage());
} catch (NullPointerException e) {
    log.warn("Could not find flow in repository with id ${executionKey} " + e.getMessage());
} finally {
    if (flowExecutionLock != null) {
        flowExecutionLock.unlock();
    }
}

想法?

有没有人知道我怎么能做到这一点。在会话中的两个流(其中一个流不完整)之间交换应该是可能的,对吧?我想要一个干净的解决方案,而不是自己调整流程。

4

1 回答 1

0

我似乎找到了一种解决方法,在 g:link 标记中(我在其中创建流的链接)我并不总是习惯像在 Grails 中那样添加动作“索引”,但它似乎当我添加它时,我能够在流之间无缝切换。

<g:link absolute="true" controller="contact_us" action="index">

我不确定是否从流存储库中删除了旧流。我尝试在两个流之间单击 70-80 次,但日志中似乎没有出现任何内容。如果我确实遇到任何问题,我会回来更新答案。

于 2013-09-16T19:28:22.980 回答