Signatures of dwr

Source: Internet
Author: User

The signatures section enables DWR to determine the Data Type stored in the collection. For example, in the following definition, we cannot know what type is stored in the list.

Public class Check
{
Public void setLotteryResults (List nos)
{
...
}
} The signatures section allows us to imply what type DWR should use for processing. The format is easy for anyone who understands the generic type of JDK 5.

<Signatures>
<! [CDATA [
Import java. util. List;
Import com. example. Check;
Check. setLotteryResults (List <Integer> nos );
]>
</Signatures> Another parser in DWR is dedicated for this purpose, so JDK1.3 DWR works even in your environment.

The parsing rules are basically the same as the expected rules (with two exceptions), so the types under java. lang will be imported by default.

The first is the parser bug in DWR1.0. in some environments, the correct type cannot be returned. So you don't need to worry about it.

The second is the "sunny day" Parser for this parser. That is to say, it is very loose and does not want the compiler to strictly ensure that you are correct. So sometimes it will allow you to lose the import:

<Signatures>
<! [CDATA [
Import java. util. List;
Check. setlotteryresults (list <integer> );
]>
</Signatures> A more formal parser will be used in future DWR versions. This compiler will be defined based on official Java, so you 'd better not use too much of this not strict stuff.

The signatures section is only used to determine the type parameters in generic parameters. DWR determines the type by its own reflection mechanism or runtime type, or assumes it is a string type. Therefore:

Signatures is not required-no generic parameters:

Public void method (string P );
Public void method (string [] P); signatures-DWR cannot be determined through reflection:

Public void method (list <date> P );
Public void method (Map <string, wibblebean> P); correct guesses without signatures-DWR:

Public void method (list <string> P );
Public void method (Map <string, string> P); signatures-DWR is not required and can be determined by the runtime type:

Public list <date> method (string P); there is no need to make keys of all objects in Javascript belong to the string type-you can use other types as keys. However, they will be converted to the string type before use. Dwr1.x converts the key into a string using the Javascript feature. Dwr2.0 may use the tostring () method to perform this conversion in the service segment.

 

This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/impeller/archive/2008/04/09/2271263.aspx

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.