我有一个带有两个 webflow 的 Grails 应用程序:
- 一个用于采购
- 另一个与我们联系
问题:
用户可能会在购买向导中执行多个步骤(通过网络流),然后他/她决定他们有问题并尝试与我们联系(也通过网络流)。因此,用户点击了我们导航菜单上的“联系我们”链接,但他们又回到了购买流程中的最后一步。我个人认为这与会话中的“执行”键有关,每个链接都以 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();
}
}
想法?
有没有人知道我怎么能做到这一点。在会话中的两个流(其中一个流不完整)之间交换应该是可能的,对吧?我想要一个干净的解决方案,而不是自己调整流程。