Ajax/DWR/struts instance Development)

Source: Internet
Author: User

2005 is the most popular year of Ajax, And the Ajax applications that use Gmail as a pioneer have gradually become deeply rooted in the hearts of the people. Maybe this is the so-called reincarnation. The design of the computer interface is from first thin to then fat to thin, and now it is again fat. However, there are many differences between the fat web interface and the fat web interface. The fat web interface mainly depends on dhml and JavaScript. This is the reason for this article. I believe that many oo developers are reluctant to deal with the effects of the page layer, especially the Javascript development language. I am also one of them, I really don't like JavaScript. The syntax is loose and the structure is complex. I don't like it anyway, but in the Web Age, since it is popular with fat people, it is impossible to use JavaScript. How can we simplify Ajax development? DWR was extended. He encapsulated XMLHttpRequest and directly called the server method, saving a lot of JavaScript.
Although struts has begun to take a steep step, combining DWR with Struts is still the choice of most developers.
This article consists of two parts: Framework introduction and instance development. First come:

Part 1 framework Introduction

I. Ajax Introduction
Ajax -- Asynchronous JavaScript and XML, Asynchronous JavaScript and XML.
The name contains components of Ajax: XMLHttpRequest, JavaScript, and XML for asynchronous processing.
Where:
1. XMLHttpRequest is a key part of Ajax. It is precisely because of its existence that fat people become more and more popular.
2. Javascript is an essential part of Ajax.
3. XML is a recommended method for Ajax data format, but it does not need to be used.
Of course, CSS is indispensable. CSS makes it easier to modify the user interface in Ajax.
I will not talk about the details and examples of Ajax. Find more than N resources.

II. Introduction to DWR
DWR-Direct Web remote, which is translated for direct remote webpage access. (This web has never been able to find good words for expression. Use the web page here)
As described in the name, the main feature of DWR is that you can directly call methods on the server in Ajax. It's amazing. That is to say, you do not need to use URLs to tell the service for processing, but directly call the class method in JavaScript and return data.
DWR simplifies Ajax development:
1. it encapsulates the use of Ajax and does not need to directly use XMLHttpRequest. This is very important and reduces a lot of JavaScript.
2. The callback function simplifies error processing and data return processing.
3. Directly calling server-class methods does not need to be URL-based or saves a lot of trouble.

The main components of DWR are: DWR. xml/engine. JS/util. js. The former is the configuration file used by the DWR servlet, and the latter is the Ajax file encapsulated by DWR for us.CodeOf course, other useful functions are also provided.

Iii. Struts Introduction
Is struts still used? Have you heard of it? So you don't have to look down. Take a rest. ^_^
Let's talk about how to call the Action Method in struts in DWR. To put it bluntly, it is impossible. Isn't that plain text? # $ @$ % @#
In fact, although DWR supports method calls, how can actionforward/actionform/actionmap be generated before DWR calls the method? I don't know, so DWR's support for struts is actually to refactor the method in the action, remove the above, and then you can (this is what DWR said, it's not what I said about ^_^ ).

After reading the previous introduction, I don't know if you have any feelings. I also think that I have written too little. I may have read something similar to not reading it. However, I want you to understand these concepts. The second part will be written in the form of instance development, which makes it easier to draw images based on samples (I also like this method ).

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.