Custom object conversion between flex and Java

Source: Internet
Author: User

Http://www.1v5.com/blog? Action = show & id = 81

Custom object conversion between flex and Java

Prepare to use Flex + LCDs + spring + hibernate as an OA system

I am confused about a lot of problems because I am new to flex.

Yesterday I tried flex to interwork with Java through LCDs, but there is still a problem,

How to pass custom objects between flex and Java.

I searched the relevant information on the internet today and found the solution as follows:

First, let's take a look at the as Vo
ActionScript code
Package com. Bean
{
[Bindable]
[Remoteclass (alias = "com. Bean. userbean")]
Public class userbean
{
Public var name: string;
Public var pass: string;
}
}

[Remoteclass (alias = "com. Bean. userbean")] defines the corresponding JavaBean

Note that the attribute must be public and the attribute name must be consistent with the attribute name in JavaBean.

View JavaBean
Java code
Package com. Bean;

Public class userbean {
Private string name;
Private string pass;

Public String getname (){
Return name;
}

Public void setname (string name ){
This. Name = Name;
}

Public String getpass (){
Return pass;
}

Public void setpass (string pass ){
This. Pass = pass;
}
}

In this way, objects in ActionScript can be converted to objects in Java.

LCDs automatically converts this as object to a JavaBean object.

However, if the conversion from Javabean to as objects is in the AS, forced type conversion is required.

ActionScript code
Private function result (E: resultevent): void {
VaR UB: userbean = userbean (E. Result );
}

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.