Yuan honggang: Ajax, just a transitional technology

Source: Internet
Author: User

Abstract: Ajax is actually a transitional technology with a new bottled old wine. I believe it will be replaced by new technologies in the next one to two years, it is difficult to form a highly abstract framework-level solution to solve the problem, while JSF is a scalable framework-level solution. In the next-generation J2EE specification Java EE 5.0, JSF has been put into a very important position.CommunityIt tries to unify the development modes and methods of Web applications through JSF. As a member of the JCP organization, Kingdee middleware is about to launch the Chinese-made apusic JSF ......

1 Preface

Java Server faces (JSF) technology has been put into a very important position in J2EE's next-generation specification Java EE 5.0. The J2EE community tries to use JSF to unify the development modes and methods of Web applications.

Compared with the traditional development Model Based on JSP/servlet, JSF can bring many benefits, such:

Customizable rich UI Components
Good Event Response Mechanism
Expression Language)
Automatic conversion and verification of form data
MVC-based framework model...

But at the same time, we have to see that common JSF engines in the industry have some defects and deficiencies (not to mention the limitations of the JSF technical model itself, but some problems arising from the conventional implementation mechanism), and these deficiencies may have a negative impact on JSF becoming the mainstream web application development technology in the future, including:

The conventional JSF implementation mechanism is not very ideal for runtime performance.
Lack of good tool support

As a member of the JCP organization, how does Kingdee middleware think about JSF technology? Is it intended to fully support JSF? What are the solutions used to overcome the above problems?

2. JSF and Ajax

When talking about web development technology, we have to mention Ajax. This is the concept that the entire it world is booming. Here I want to explain what Ajax is, but we can have a basic understanding of Ajax.

Ajax is actually a new bottled old wine technology. Its advantage is that it provides an asynchronous programming model through Java Script and DHTML, so that our web applications can bring a better human-machine experience to our customers. However, Ajax has a very low problem-solving level; or, it is difficult to form a highly abstract framework-level solution by using methods and means to solve the problem, while JSF is a scalable framework-level solution.

In fact, I think Ajax is a transitional technology, and I believe it will be replaced by new technologies in the next one to two years, it is Microsoft's XAML, Mozilla's XUL, or any possible Ria standard. In fact, the entire industry is watching. However, no matter what technology is used, JSF can adapt. For JSF, adapting to a new technology is simply replacing a render kit. For example, if you want to implement chart functions on a webpage, MSIE has VML, Gecko, and opera have SVG, on the server side, you only need to simply judge the browser type and select a render kit to generate different markup to accomplish the same function. This is a task that is difficult to accomplish with the conventional JSP technology.

3 apusic JSF: The JSF engine made by the Chinese/

3.1 container-level Ajax support

Currently, the idea of JSF + Ajax is not a kind of Kingdee middleware either, however, many third-party JSF + Ajax implementations provide a component library and an additional servlet or filter to process Ajax requests. However, we directly use the JSF container to process Ajax requests. We will determine whether this is a normal HTTP request or an Ajax request based on the request type. For a regular HTTP request, run the JSP page to generate the page document (and we will embed the Java Script required by Ajax in the generated page documentCode); If the request is an Ajax request, the server decodes the Request Parameters and executes all stages except the page output stage in JSF, a jsf component tree is generated to traverse the component tree, identify the changed data, and package the data into an Ajax response, the client updates the modified data and even changes the page appearance.

In the JSF specification, the render Kit Used in the JSF page output stage can be replaced. The default html_basic render kit outputs standard HTML syntax and does not contain any Java script code, the apusic JSF engine implements an Ajax render kit. You can embed Java script code in the HTML document to implement Ajax features. To replace the render kit, you only need to modify the configuration file.

So what are the benefits?

3.2 improve the running performance of JSF and provide a better human-machine experience.

The general State maintenance practices of JSF containers are session-based or request-based. This means that each time the client and server respond, all the statuses need to be transmitted, which will undoubtedly have a great negative impact on the system running performance, so that developers mistakenly think: JSF is a heavyweight technical model.

With the Ajax feature of apusic JSF, we can only package changed data into Ajax requests and send them to the server, the server only packs changed data into Ajax responses, which greatly improves the system running efficiency. In addition, the traditional JSF request response will refresh the entire page, while apusic JSF will only update the changed client components, so as to bring a better human-machine experience to the customer.

3.3 simplify Ajax Development

In the past, I had to write a lot of Java Script code for Ajax applications. The development, debugging, and maintenance of these script scripts are cumbersome. If you use the apusic JSF technology, you no longer need to write any Java script code, the engine has generated the code for you. All standard components of apusic JSF support Ajax. some third-party components may not support Ajax, but use a tag named <Ajax: rendergroup>, you can immediately convert this third-party component to Ajax enabled. For example, the Tomahawk project of Apache MyFaces provides a tree component, which does not support Ajax itself. Every time you press a tree node, the entire page is refreshed and <Ajax: after the rendergroup> label, only the tree part is refreshed, instead of the other part of the page. Of course, a better way is to provide a tree component that supports ajax to reduce the transmission of redundant data.

Apusic JSF also provides a tag named <Ajax: Status> to accept events triggered when an Ajax request is sent and completed, by default, an HTML segment is displayed before an Ajax request is sent. After an Ajax request is completed, another HTML segment is displayed, which can contain text and images. In more advanced usage, you can set the onstart and onstop attributes of the <Ajax: Status> tag, and execute a Java Script code to start and complete Ajax requests to achieve more complex results.

In addition, we also implement a <Ajax: invoke> label that can call a method of the server-side Java object in RPC mode.

3.4 other features

The adoption of apusic JSF also includes some other differentiated features, including the skin-changing function of controls, support for multiple browsers such as IE, Mozilla (Firefox) and opera, and powerful layout functions.

Figure 1 windows-style apusic JSF components and Layout

 

In <Figure 1>, the interfaces generated by apusic JSF are completely HTML-based, CSS-based, and Java Script interfaces. They are almost the same as those of a real window system, it includes moving location, changing stack order, and mode dialog box, but they are all "fake" windows. In addition, it should be emphasized that CSS layout is fully used here, avoiding the old layout that relies on HTML table nesting, so that ourProgramIt has better maintainability. For such an interface, we can observe the specific implementation code. Take the main window in <Figure 1> as an example:

< W: Window Jsvar = "Mainwnd" Label = "Main Window" Show = "True"
Left = "0" Top = "0" Width = "500" Height = "350"
Contentpanestyleclass = "Normal-window"
Showicon = "True" Showminimize = "True" Showmaximize = "True" Showclose = "True"
Onclose = "Registry.location='index.html '" >
< H2 > Main Window </ H2 >
< P >
< Button Onclick = "Createwindow ()" > Create window </ Button >
< Button Onclick = "Dlgtest. Show ()" > Show Dialog </ Button >
</ P >
<% @ Include File = "/WEB-INF/apusicjsf. Inc" %>
</ W: Window >

We found that implementing the preceding UI through apusic JSF is not complicated. You only need a few lines of code to complete the complex UI.

Apusic JSF also supports skin replacement of controls. The preceding interface is used as an example. You can view the Mac OS style, as shown in figure 2.

4. Support for development tools: apusic Studio

In the JSF specification, there is a saying: "JSF is designed to be tooled ". In other words, the JSF specification emphasizes the dependency on tool support from the beginning of the design. Fortunately, the development tools supporting JSF are gradually enriched, including Oracle jdeveloper and Sun Java Studio creator. Kingdee middleware also provides an eclipse-based integrated development environment: apusic studio, which can provide good support for JSF development, including: highlight the syntax, code assistance, breakpoint debugging, visual design, and so on.

Figure 2 Examples of Mac OS-style apusic JSF components and Layout

5 References

Note: apusic application server, apusic studio see http://www.apusic.com

Author's link: "20 people affected Chinese software development" yuan honggang (http://news.chinabyte.com/334/1760834_3.shtml)
"Character: Yuan honggang, company: Kingdee middleware Company
Reason for enrollment: the earliest development of enterprise application software on Windows to create an EJB server with independent intellectual property rights
Many Java programmers admire yuan honggang very much because he did something that many people did not dare to do. This is why he created a domestic EJB server and soon, kingdee will launch the 3.0 version of its proprietary EJB server in China.
At the same time, Yuan honggang was the first programmer to develop enterprise application software on the Windows platform. At that time, he wrote Kingdee 2.7, an integrated financial purchase software suitable for small enterprises, the IT industry has a strong view of Kingdee, making Kingdee famous. These talents have laid the foundation for Chinese management software.
Yuan honggang wrote his many years of experience in a simple style. These posts have far-reaching influence on the Internet ."

For more information, please visit yuan honggang viewpoint area: http://www.apusic.com/market/javaclub/yuan/

Related Article

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.