Spring webflow:在视图状态之间移动
在 Spring Webflow 中,我需要实现一个导航栏,该导航栏允许“后退”或将流程恢复到前一个视图之一。
例如:
- 视图 1 = 登录
- 视图 2 = 我的信息
- 视图 3 = 我的消息
- 视图 4 = 关闭会话
对于此示例,我想从视图 4 页面返回到视图 2。
Within a spring webflow, i need to implement a navigation bar that will allow to "step back" or resume the flow to one of the previous view.
For example :
- View 1 = login
- View 2 = My informations
- View 3 = My messages
- View 4 = Close session
For this example, i would like to return back to view 2 from the view 4 page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于你打算如何做这件事。 如果您在单个流程中执行此操作,您将看到如下内容:
“closeView”上的“jumpBack”转换会将您跳回视图状态#2,这是您的信息视图。
对于子流程来说,这很棘手。 您需要将其链接起来:调用子流,如果发出事件信号表明您需要以特定状态结束流,请立即执行此操作。
例如,假设您的流程链是登录->信息->消息->关闭。
在关闭流程中,最终状态将是“returnToInformation”。
消息流有一个从“returnToInformation”到“returnToInformation”的转换。
“returnToInformation”也是消息流中的最终状态。
然后,信息流从“returnToInformation”转换为“displayInformationPage”,然后重新显示信息页面。
It depends how you're going about doing this. If you're doing this within a single flow, you'll have something like this:
The "jumpBack" transition on "closeView" will jump you back to view state #2, which is your information view.
With sub-flows it is tricky. You'd need to chain it: call a subflow, and if an event is signaled that states you need to end your flow with a specific state, immediately do so.
For example, say that your flow chain is login->information->message->close.
On the close flow, the end-state would be "returnToInformation".
The message flow has a transition on="returnToInformation" to="returnToInformation".
"returnToInformation" is also an end-state in the message flow.
Then, the information flow has a transition on="returnToInformation" to="displayInformationPage", which would then re-display the information page.
我通过定义一些代表选项卡的全局流来做到这一点。 然后,我定义了一个对象,该对象表示流上的选项卡并指示当前选项卡是否处于活动状态。 当用户浏览选项卡时,我根据需要更新了选项卡对象。
当用户点击其中一个选项卡时,它使用全局流来允许它们在选项卡之间移动(对于我的实现,我发现调用操作比调用视图状态更容易,因为您可能会发现视图可能会根据用户交互才能到达那里,因此您可能需要重新计算它们)。
对于选项卡栏本身,我将其放在一个 JSP 中,然后将其放置在每个表单的顶部,这使得更新变得更加容易。
这不是最好的解决方案,但它确实有效。
祝你好运。
I did this by defining some global flow that represented the tabs. I then defined an object that represented the tabs on the flows and indicated if the current tab was active. When the user moved through the tabs I updated the tab object as appropriate.
When the user went to click on one of the tabs it used the global flows to allow them to move between the tabs (for my implementation I found it easier to call actions rather than view states because you may find the views may change depending on the user interaction to get there so you may need to recalculate them).
For the tab bar itself, I put it in a single JSP that I then placed at the top of each form, this made updating it easier.
Its not the nicest solution, but it does work.
Good luck.