STRUTS/TAPESTRY/JSF Comparison of performance layer frames

Source: Internet
Author: User
Tags comparison config functions implement requires
js| comparison STRUTS/TAPESTRY/JSF is a framework technique for the new and old combination of the present Java EE Performance layer. From the time of birth, struts should be relatively early, use very widely, Tapestry 3.0 gradually aroused widespread attention, just as Tapestry is about to show off, Sun introduced JSF standard technology, although the JSF first launched is not mature, set aside a period of gap, But with the introduction of the JSF1.1 Standard, JSF began to hit the front, and the powder noodles came into a grand debut.

In fact, JSF and tapestry are not the same competing technologies for head-meeting, both of which are focused, but subtle, but the nuances may bring different feelings and changes in achieving a large project.

First, we abstract from a height the technical framework that the presentation layer framework should have, and the following diagram shows the functional architecture diagrams that all presentation layer framework technologies must implement:

Of course, we don't have to talk about the MVC pattern, the MVC pattern is the benchmark, and now the framework technology doesn't have to spell the MVC pattern anymore. On the basis of the MVC pattern above, a presentation layer framework does not need to implement three functions in the diagram:

1. It is possible to display the contents of a Component object on the current page, instead of writing the Java Code "invoke object Method" in the JSP page like a pure JSP.

2. When the user presses the page submission button or link, the event occurs, the server side should be triggered and the current page parameters submitted to the server. This mechanism is presented in form form submission and with parametric links <a href= "" ></a>

3. Jump from one page view directly to another page view, simple navigation function.

We use the table below to compare the technical details of these three frameworks in realizing the functions of the above diagram, so as to get their similarities and differences and points of focus.

Struts Tapestry3.0 Jsf
Component requirements shown in view

Component must inherit Actionform

Explicit invocation and implicit invocation
Component must inherit Basecomponent
Ordinary Pojo
No need to inherit
Managed Bean
Component in view display granularity The view page can only display the actionform that corresponds to the form, and the Action Actionform page in the configuration can generally only 1:1:1 relationship. You can embed a component in any row of the page, without restrictions on the number of components used. With Tapestry
Page Partition Tiles Using the Tiles Tag Library implementation requires additional Tiles-def.xml configuration files Component has its own view page that implements multiple page combinations directly by invoking the component. The powerful natural page combination is its feature. Through the component + Tag library to achieve subview, but if you need to reuse layout, but also with tiles.
Page Jump Use the tag library html:link to specify that the target Url,url name needs to be coupled to the component action, in contrast to the configuration file's path. The URL name is the target's component name, and does not involve the URL and the path and other operations, convenient and stable. Like struts, you also need to look in the configuration file and detach from the component.
Parameter passing Passing arguments over more than one handling problem when using Html:link. Call the component directly, give the parameter directly, no limit on the number of parameters Parameter separation passed to the component
Event triggers Submit activation via form submission and cannot be subdivided into fields in the form. To be able to put an event on each field of the form, the event component must implement the Pagelistener interface 同Tapestry,事件组件必须实习ActionListener 接口

Struts Assembly programming Model

Struts implements component programming with some complexity: it is often a headache to introduce multiple components into a single page, because struts cannot directly introduce multiple components and must circle some circles:

There are two general scenarios: if the same action can deal with these components, there are two ways to do this:

1. Load these components into a actionform, such as the use of mapform mechanisms;

2. Manually load multiple components into scope such as request/session, and then obtain them in the JSP according to their name.

Both methods have their drawbacks: the first approach is often a actionform and becomes a hodgepodge, violating the principles of OO dispatch encapsulation; The 2nd approach is actually back to JSP programming;

In the second case, if these components have to be handled in advance by different action, each component must go through the action-->actionform process, in which case there are two ways:

1. Using tiles, different processes are exported to different areas of the same page. is a parallel processing method.

2. To multiple processes End-to-end, the first action forward result is the second action, the final output of a JSP, in this JSP can use the previous multiple actionform of the process, this is a serial mode.

Struts Component Model disadvantage

Struts component programming must be limited to action/actionform/jsp these three frames, the difficulty is relatively large, and TAPESTRY/JSF is not too many of these technical constraints, both in the component programming to let programmers more free, more convenient, This is also the advantage of the modular framework.

Struts Tag Library

In struts, often need to use tag library to display component Actionform content, which involves a combination of problems, tag library is written by others, refer to the use of Struts tag library, and components are their own, difficulty and trouble is reflected in this point.

JSF basic ideas and struts almost, but the different tag library, but also need to tag library + components of the combination of thinking, but because the component here is a common component, there is no limit, so this is easier than struts.

Tapestry uses the component library concept to replace the tag library, without the tag library concept, so there is no question that the tag library and its components need to be combined, it is the use of components, components are divided into tapestry standard components and their own defined components, This is also contact with the JSP system of people learning tapestry face a transformation of thinking.

Specific to the page jump to an example, page jump is by link <a href= "goal" ></a> implementation, links are often used in the page elements.

The html:link provided by struts is especially inconvenient to use frequently, especially when passing multiple parameters: the page value of Html:link is the path to jump to the other's pages or action. This path typically requires a corresponding path to the Struts-config.xml lookup action, and once the configuration file path value is modified, all related pages are modified.

JSF divides the concept of links into two areas: navigation and event activation, or the From-outcome value of the configuration Faces-config query navigation.

Since tapestry does not have a tag library concept, only a component or page concept, so the link jump target is either a component or a page, and it has no redundant path concept, which is the component name, which is the object name, the component name and the path name.

Summarize

JSF is a lot like struts, not like tapestry, a kind of struts 2.0 that takes the form of tag libraries + components, but JSF's component concepts do not have to inherit actionform restrictions like struts ; JSF is delicate on event granularity, unlike struts, a form event, JSF can be refined to each field in the form.

JSF is only similar to tapestry in terms of component and event mechanism, but it is not like tapestry is a complete component frame, so if you do a system with a high degree of flexibility to page requirements, choosing Tapestry is the first consideration.

STRUTS/JSF is suitable for the General data page input system, for struts and JSF selection, my current personal view is: If you are a new system, you can start directly from JSF, if you have used struts, do not have to convert, if you need to switch, JSF and tapestry can be considered together.

In addition, jsf/tapestry not only supports HTML, but also supports a variety of client languages such as WML or XUI.

The relationship between the three: if struts is the left, the tapestry is the right, while JSF is the centrist, and the doctrine of the Golden mean is the consistent strategy of the Sun Alliance.

Of course, you can also publish your experience of using any one of these three in practice to make a comparison between those who come later.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.