简体   繁体   English

如何在Java Web应用程序中实现复杂的页面流

[英]How to implement a complex page flow in a Java Web application

I am trying to implement a reasonably complex page flow (100+ pages) as a traditional web application. 我正在尝试实现一个相当复杂的页面流(100多页)作为传统的Web应用程序。 I found a few options, but none of them are 100% convincing 我找到了一些选择,但没有一个是100%令人信服的

  1. Hand code the flow into the controllers, do redirects, etc. This is obviously not the best thing for maintenance 手动编码流入控制器,进行重定向等。这显然不是维护的最佳选择
  2. JSF not only handles the flow, but also requires to use JSF as the view technology. JSF不仅处理流程,还需要使用JSF作为视图技术。 I don't like this lock-in 我不喜欢这种锁定
  3. Spring web flow. 春天的网络流量。 The current version 2.3.1 defines flows in XML that is not easy to maintain. 当前版本2.3.1定义了不易维护的XML流。 The upcoming 3.0 release promises to define flows with annotations in pure java, but it does not even have a timeline. 即将发布的3.0版本承诺在纯java中使用注释定义流程,但它甚至没有时间轴。 Additionally the project development slowed down significantly in the past years. 此外,项目开发在过去几年中显着放缓。
  4. GWT and Vaadin's concept is closer to a traditional desktop application then to a web application, that is really convenient to use, but it wont fit to my project. GWT和Vaadin的概念更接近于传统的桌面应用程序,然后更接近Web应用程序,这非常方便使用,但它不适合我的项目。

Additionally I found dozens of abandoned projects like this: http://javasteps.sourceforge.net/ 此外,我发现了许多像这样的废弃项目: http//javasteps.sourceforge.net/

I am wondering why all these projects are abandoned, what is the way to implement a complex page flow in 2012? 我想知道为什么所有这些项目都被放弃了,2012年实现复杂页面流的方式是什么?

Personally, I'd recommend Single Page Architecture: 就个人而言,我推荐单页架构:

Architecture of a single-page JavaScript web application? 单页JavaScript Web应用程序的体系结构?

I'm not sure if that is feasible or not with your application. 我不确定您的申请是否可行。 I've used all the flows you mentioned above and am currently working on a single-page application and I love it. 我已经使用了你上面提到的所有流程,目前正在处理单页应用程序,我喜欢它。 We're using Dojo on the client-side, which calls a REST API on the server. 我们在客户端使用Dojo,它在服务器上调用REST API。 It's been pretty nice. 一切都很好。

Vaadin is pretty solid too and is much easier to set up than just bare-bones GWT. Vaadin也很稳固,而且比简单的GWT更容易设置。 If you have a lot of UI guys on your project that like to code in CSS and Javascript, they'll hate that approach though. 如果您的项目中有很多UI人员喜欢用CSS和Javascript编写代码,他们会讨厌这种方法。

Spring Webflow is pretty solid actually. Spring Webflow实际上非常可靠。 I haven't looked at it in a while, but when I was using it, it got the job done for what I worked on at the time. 我有一段时间没有看过它,但是当我使用它时,它完成了我当时工作的工作。

There is a new MVC framework and web flow implementation for Vaadin component model called Lexaden Web Flow Vaadin组件模型有一个名为Lexaden Web Flow的新MVC框架和Web流程实现

You can try it out for your application as possible alternative. 您可以尝试将其作为应用程序的替代方案。

This is really late but I don't see a satisfactory answer to this question and would like to share an approach I had tried in a recent project which I feel is better than the spring web flow approach which is strictly tied down to spring views. 这已经很晚了,但我没有看到这个问题的满意答案,并希望分享我在最近的一个项目中尝试过的方法,我觉得这比春天网络流程方法更好,这种方法严格地限于春天的观点。 I created a SPA using angular js with Spring MVC. 我使用带有Spring MVC的角度js创建了一个SPA。 In angular js I did not use routers or state, rather I created a div within the controller like below 在角度js我没有使用路由器或状态,而是我在控制器中创建了一个div,如下所示

<div width="100%" id="fullertonDataPanel" ng-include="page"></div>

On the server side to capture all possible transitions from one frame(I am referring to a particular screen in the SPA) to another I created a tree of rules using MVEL . 在服务器端捕获从一个帧(我指的是SPA中的特定屏幕)到另一个帧的所有可能的转换,我使用MVEL创建了一个规则树。 So in the database I had a structure which stored a tree of rules for every frame . 所以在数据库中我有一个结构,它存储了每个帧的规则树。 The data in the MVEL expressions were being set by the various services each action invoked. MVEL表达式中的数据由每个操作调用的各种服务设置。 Thus on any action the following steps were followed. 因此,在任何动作上遵循以下步骤。

1) Validate the action. 1)验证操作。

2) Invoke various services. 2)调用各种服务。

3) Capture the data from these services and merge it with the existing data of the user. 3)从这些服务中捕获数据并将其与用户的现有数据合并。

4) Feed this captured data into collection of rules for each frame along with the details of the current frame. 4)将捕获的数据馈送到每个帧的规则集合以及当前帧的细节。

5) Run the rules of the tree wrt to current frame and fetch its output. 5)将树的规则运行到当前帧并获取其输出。

6) If there is only one transition then that is the final transition. 6)如果只有一个转换,那么这是最后的转换。 If there are 2 transitions and one is default then ignore the default transition and use the other transition. 如果有2个转换且其中一个是默认转换,则忽略默认转换并使用另一个转换。

7) Return the template name of the transition to the angular controller and set the value of the page variable in the scope of the controller. 7)将转换的模板名称返回到角度控制器,并在控制器范围内设置页面变量的值。

Using this approach all my services had to do was store data in different data fields wrt a particular action. 使用这种方法,我所有的服务必须做的是将数据存储在特定操作的不同数据字段中。 All the complex if-else conditions for Web Flows or any complex process definitions(like the one defined in Spring-Web Flow) were not required. Web Flow的所有复杂的if-else条件或任何复杂的流程定义(如Spring-Web Flow中定义的那些)都不是必需的。 The MVEL rule engine managed all that and since it was all in the database it could be changed without needing a server re-start. MVEL规则引擎管理了所有这些,因为它全部在数据库中,所以可以在不需要重新启动服务器的情况下进行更改。

I believe this generic approach with MVEL is a flexible approach which comprehensively handles the problem of a convoluted flow without making the application code a mess or adding additional unnecessary xml files. 我相信这种使用MVEL的通用方法是一种灵活的方法,可以全面处理复杂流的问题,而不会使应用程序代码变得混乱或添加额外的不必要的xml文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM