Yuan Honggang: Ajax is just a transition technology

xiaoxiao2021-04-08  298

Abstract: Ajax is actually a transition technology for new bottles of old wine. It is believed that it will be replaced by new technologies in the next one to two years. It is difficult to solve problems and means to form a highly abstract frame level. The solution, while JSF is an extensible framework-level solution. In J2EE next-generation specification JAVA EE 5.0, JSF is placed in a very important position, and the J2EE community attempts to unify the development model and method of the web application through JSF. As a JC-organization member of the JCP organization, the APUSIC JSF made by Chinese people is about to launch the Chinese.

1 Introduction

In J2EE Next-generation specification JAVA EE 5.0, JSF (Java Server Faces) technology is placed in a very important position. J2EE community attempts to unify the development model and method of the web application through JSF.

Compared to traditional JSP / servlet development models, JSF can bring a lot of benefits, such as:

Customizable Rich UI Component Good Event Response Mechanism Expression Language Form Data Automatic Conversion and Verification Based on MVC Frame Model, etc. ...

But at the same time, we have to see that there are some shortcomings and shortcomings in the industry's common JSF engine (not to say the JSF technology model itself, but some problems generated by the routine implementation mechanism), and these shortcomings will It has a negative impact on the mainstream development technology of Web applications in the future, including:

Conventional JSF implementation mechanism, operational performance is not very ideal for good tool support

As a member of the JCP organization, how is the JSF technology to treat JSF technology? Is it intended to fully support JSF? What solutions have been overcome by how to overcome the above?

2 JSF and AJAX

When I talk about Web development technology, I have to mention AJAX. This is currently the concept of purple in the entire IT world. Here I don't want to explain what is AJAX again, but we can have a basic understanding of Ajax.

Ajax is actually a new bottle of old wine technology, which provides an asynchronous programming model through Java Script and DHTML, making our web app to bring a better human machine experience. However, the level of Ajax is very low; or, it solves the methods and means of the problem, it is difficult to form a highly abstract frame-level solution, while JSF is an extensible frame-level solution.

In fact, I think Ajax is a transitional technology. I believe that in the next year to two years will be replaced by new technologies, it is Microsoft's XAML, Mozilla XUL, or any possible RIA standard, actually the entire industry Watching. But no matter what technology, JSF can be adapted, adapt to JSF to accommodate a new technology just replace a render kit. For example, if you want to implement chart function (Chart) in the web, Msie has VML, Gecko, and Opera have SVG, and only simply determine the browser type in the server, you can choose a render Kit to generate different Markup. Complete the same function, this is a task that is difficult to complete with conventional JSP technology.

3 APUSIC JSF: The Chinese people's JSF engine / 3.1 container level Ajax supports this idea of ​​JSF AJAX, I am afraid it is not a Kingdee middleware, but many third-party JSF AJAX implementation is a component library. And an additional servlet or filter to process AJAX requests, and we are directly processed by the JSF container to process AJAX requests. We will determine according to the type of request, which is a normal HTTP request or an AJAX request. If you are a regular HTTP request running a JSP page, generate a page document (and we will embed the Java Script code must be in the generated page document, mention later); if the request is an AJAX request, the server is requested The parameter is decoded normally and performs all other phases other than the page output phase in JSF. At this time, a JSF component tree will be generated, traverse the component tree, and find out the changed data, and package the data into an AJAX response And by the client update these modified data, and even change the appearance of the page. In the JSF specification, the render kit used in the JSF page output phase is alternative. The default HTML_BASIC RENDER KIT output is a standard HTML syntax, which does not contain any Java Script code. The APUSIC JSF engine implements an Ajax Render Kit, you can Embed a Java Script code in the HTML document to implement the AJAX feature, and replace the Render Kit only needs to modify the configuration file. So what is the benefit of this? 3.2 Enhance JSF Running Performance, bringing a better human machine experience. General practices for regular JSF containers in status maintenance are: based on session, or based on request transmission type, this means that when each client is responsive to the server side, you need to pass all the status. This undoubtedly brings a large negative impact on the operating performance of the system, making the developer as: JSF is a technique model of heavyweight. Through the AJAX characteristics of APUSIC JSF, we can only pack changes in data to a AJAX request to send to the server, and the server side will only package the changed data into a AJAX response, which greatly enhances the operating efficiency of the system. Also, the traditional JSF request response will refresh the entire page, and the APUSIC JSF will only update the changeable client component, which gives customers a better human machine experience. 3.3 Simplified AJAX Development To write ajax app to write a lot of Java Script code, development, commissioning, and maintain these Script scripts are quite cumbersome. If you use Apusic JSF technology, you no longer need to write any Java Script code, the engine has helped you These code. All standard components of APUSIC JSF are supported by Ajax. Some third party components may not support AJAX, but use a label called , you can immediately convert this third party component to ajax enabled. For example, the Tomahawk project of Apache MyFaces provides a Tree component. This component itself does not support AJAX. Whenever a TREE node will re-refresh the entire page, use the tag to refresh the TREE section, and Do not refresh the other parts of the page. Of course, a better way is to provide a Tree component that itself supports Ajax to reduce the transfer of redundant data.

The APUSIC JSF also provides a label called , which can accept events triggered when sending and completing an AJAX request. The default implementation shows an HTML fragment before sending AJAX requests, after completing the AJAX request. Displays another HTML fragment that can include text and images. More advanced usage is to set the onStart and onStop properties of the tag, perform a Java Script code when starting and completing the AJAX request to achieve more complex effects. In addition, we also implements a tag that can call a method of server-side Java objects in RPC. 3.4 Other features Adopt APUSIC JSF also contains other differential features, including: controlled skin regeneration, controls for IE, Mozilla (Firefox), Opera, etc., and powerful layout features. Figure 1 Windows style APUSIC JSF component and layout shown in

is the entire HTML, CSS, Java Script-based interface generated by apusic JSF, which is almost exactly the same as a real window system, including moving positions. , Change the stack order, and the mode dialog, etc., but actually they are all "false" windows. It is also important to point out that the CSS layout is completely used, avoiding the old-free layout of HTML Table nested, so that our procedure has better maintenanceability. In response to such an interface, we can observe the specific implementation code, which is the main window in
Take: CREATEWINDOW
转载请注明原文地址:https://www.9cbs.com/read-132914.html

New Post(0)