This is a super simple DWR configuration file that describes the most common labels of DWR.

Source: Internet
Author: User

The simplest DWR configuration description
Configuration of DWR. xml
<DWR>
<Allow>
<Create creator = "new" javascript = "testclass">
<Param name = "class" value = "com. DWR. testclass"/> -----> -----〉****
<Include method = "testmethod1"/>
</Create>
<Convert converter = "Bean" match = "com. DWR. testbean"/>
</Allow>
</DWR>
Note:
<Allow> the tag contains things that can be exposed to JavaScript access.
<Create> the tag specifies the Java class that can be accessed in JavaScript and defines how DWR gets the instance of the class to be remotely implemented.
Creator = "new" attribute specifies the Java class instance generation method. New means that DWR should call the default constructor of the class to obtain the instance. Other methods include the spring method, by integrating with the IOC container spring to obtain instances.
The javascript = "testclass" attribute specifies the name used by the JavaScript code to access the object. DWR can generate *. js files by itself, but we cannot see them within the project. Is an implicit Virtual File. This configuration generates testclass. js
<Param> label specifies the Java class name to be exposed to JavaScript.
<Include> the tag specifies the method to be exposed to JavaScript. If this parameter is not specified, all methods are exposed.
<Exclude> label specifies the method to prevent access.
<Convert> labels define the types of objects that can be returned by this class. to return an object, specify its type here.
The converter attribute is a written bean, and match is the class name of the returned object.

Calls in Javascript

First, introduce JavaScript scripts
<SCRIPT src = 'dwr/interface/testclass. js'> </SCRIPT>
<SCRIPT src = 'dwr/engine. js'> </SCRIPT>
<SCRIPT src = 'dwr/util. js'> </SCRIPT>
Testclass. JS is automatically generated by DWR according to the configuration file, and engine. js and util. js are built-in script files of DWR.
Second, write JavaScript Functions that call Java methods.
Function calltestmethod1 (){
Testclass. testmethod1 ();
}

Note:
* *** If you write it as <Param name = "class" value = "testclass"/>, this write means that this class is injected through spring in advance. Then, you must change it to <create creator = "Spring" javascript = "testclass">

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.