Spring Webflow,从任意子流程返回主流程

发布于 2024-11-03 08:46:15 字数 126 浏览 2 评论 0原文

我试图通过单击按钮从任何子流程返回到春季的主要流程。

当我使用 时,它只会转到上一个流程,这也是应用程序中的子流程。

有什么想法吗?

I'm trying to return to my main flow in spring, from any of my subflows just by clicking a button.

when I use <end-state> it just goes to the previous flow, which is also a sub-flow in the application.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深巷少女 2024-11-10 08:46:15

您只需要在调用流程中的每个子流程状态中进行适当的转换即可执行您想要的操作。子流程中的最终状态 ID 将用作您可以在调用流程中进行转换的事件 ID。

子流程可以被认为是执行的一个分支。因此,当子流程完成时,控制权将返回到调用流程。将您的最终状态视为返回语句(并将 id 属性视为返回的值 - 您还可以设置输出属性,但这在这里并不重要)。

当子流终止时,控制权将返回到调用流。调用流程应定义一个转换来确定如何处理此事件。您将看到的事件 ID 是子流程中最终状态的 ID。

因此,在您的子流程中,如果您有以下最终状态:

<end-state id="back"/>

您可以在调用该子流程的流程中处理此转换:

<subflow-state id="do-some-sub" flow="some-sub">
    < ... input variables, expressions, etc ... />
    <transition on="back" to="some-state"/>
</subflow-state>

请注意,这里的某些状态也可以是最终状态。您的情况听起来好像您有一个主流程调用一个子流程,而子流程又调用另一个子流程。因此,您希望 some-state 成为最终状态,然后由其调用流程(在您的情况下为“主”流程)处理。

You just need the appropriate transitions in each subflow-state in the calling flow to do what you want. The end-state id in your subflow is what will be used as the event id you can transition on in your calling flow.

A subflow can be thought of as a branch of execution. So when your subflow is finished, control is returned back to the calling flow. Think of your end-state as a return statement (and the id attribute as the value returned -- you can also set output attributes but that is not important here).

When your subflow terminates, control is returned backed to the calling flow. The calling flow should define a transition that determines how to handle this event. The event id you will see is the id of the end-state in your subflow.

So in your subflow if you have the following end-state:

<end-state id="back"/>

You can then handle this transition in the flow that called the subflow:

<subflow-state id="do-some-sub" flow="some-sub">
    < ... input variables, expressions, etc ... />
    <transition on="back" to="some-state"/>
</subflow-state>

Note that some-state here can also be an end-state. Your situation sounds like you have a main flow that calls a subflow which in turn calls another subflow. So you would want some-state to be an end-state, which would then be handled by its calling flow (in your case the "main" flow).

似梦非梦 2024-11-10 08:46:15

您可以通过在定义子流程时添加“父”属性来实现此目的,如下所示,

<flow parent="login" xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow  http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

<view-state id="forgotPassword">
        <transition on="backtoLogin" to="login">

        </transition>

我希望我的子流程通过后退按钮“单击”返回到登录页面。

需要注意的一件事是,在您的父 flow.xml 中,您需要指定

我的父视图的绝对路径,即下面给出的 login-flow.xml

<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow     http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">


<view-state id="login" view="../login/defaultLogin.xhtml">

You can achieve this by adding the 'parent' attribute when you define your sub flow like this

<flow parent="login" xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow  http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

<view-state id="forgotPassword">
        <transition on="backtoLogin" to="login">

        </transition>

here i want my subflow to return to the login page on a back button 'click' .

One thing to notice is that in your parent flow.xml u need to specify the absolute path of the view

my parent ie login-flow.xml is given below

<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow     http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">


<view-state id="login" view="../login/defaultLogin.xhtml">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文