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 );
}