Question about the transfer of the boolean type between flex and Java

Source: Internet
Author: User

Recently, a problem was found during the development process: Values of the boolean type cannot be passed between flex and Java. After some research, it is found that the problem occurs in the getter and setter methods of the boolean type.

According to the JavaBean specification, the getter of the small boolean type is prefixed with "is", but the getter of the big boolean type is prefixed with "get" (the big Boolean is used as the reference type, it is regarded as a common object ).

For example:

For the private Boolean enable field, the getter and setter fields are as follows: (Note: if the enable field is changed to isenable, The getter and setter fields are the following two fields)

Public Boolean isenable (){
Return enable;
}

Public void setenable (Boolean enable ){
This. Enable = Enable;
}

For the private Boolean Editable field, the getter and setter fields are as follows:

Public Boolean geteditable (){
Return editable;
}

Public void seteditable (Boolean editable ){
This. editable = editable;
}


When a Boolean value is passed to the front-end and Java backend of FLEX, the value will be serialized. When the value is parsed in the background, it will be a large Boolean Type of Java, at this time, the system will set the value based on the getter and setter of the big boolean type. If the corresponding field declared by your Java object is of the small boolean type, and the generated getter is also a prefix of is, the system cannot find getter and setter to set the value. This is the cause of the problem.

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.