DWR: Easy AJAX for JAVA

Source: Internet
Author: User

DWR (Direct Web Remoting) is a WEB Remote Call framework. using this framework can make AJAX development very simple. using DWR, you can use JavaScript on the client to directly call the Java method of the service and return the value to JavaScript, just like calling the Code directly on the local client (DWR dynamically generates JavaScrip code based on the Java class ). the latest version of DWR0.6 adds many features, such as support for automatic Dom Trees configuration, support for Spring (Remote JavaScript call of spring bean), and better browser support, an optional commons-logging log operation is also supported.

DWR: Easy AJAX for JAVA

DWR is a Java open source library that helps you implement Ajax websites.

It allows you to use Javascript code in the browser to call Java on the Web server, just as in the Java code in the browser.

DWR consists of two parts:

  • The Servlet running on the server processes the request and returns the result to the browser.
  • Javascript running on a browser can send requests and dynamically change pages.
    DWR dynamically generates Javascript code based on your Java class. The magic of these codes makes you feel that the entire Ajax call occurs on the browser, but in fact the server executes the code, and DWR is responsible for data transmission and conversion.

This remote call between Java and Javascript makes DWR users feel like the RMI or soap rpc mechanism they used to use. In addition, no additional browser plug-ins are required for this process.

Java is synchronous, while Ajax is asynchronous. So when you call a remote method, you need to call a callback function for DWR. when data is returned from the network, DWR will call this function.


This figure shows how DWR changes the content of the drop-down list in The onclick event.

DWR dynamically generates a corresponding client AjaxService class (Javascript) for the server AjaxService class (Java ). This class is called by eventHandler. DWR will process the details of the entire Remote Call, including converting parameters and return values between Javascript and Java. In this example, it will execute the callback function you provided (populateList). This function uses the tool function provided by DWR to change the page content.

DWR helps you produce websites with good interactivity. It provides some Javascript libraries to help you process DHTML and provides some examples for reference.

To learn how to start using DWR, you can see the start guide and download DWR.

The client should not directly call the server method, which increases the coupling between the client and the server.

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.