While passing data (Data Serialization) from Java (server) to Flex (client) the names of the object are getting changed. Please find the details below.
Java Pojo
public class MSC
{
public String Column1;
public String Column2;
}
Java Remote Class
public List<MSC> getData()
{
MSC pojoMSC = new MSC;
pojoMSC.Column1 = "1";
pojoMSC.Column2 = "2";
List<MSC> listMSC = new ArrayList<MSC>;
listMSC.add(pojoMSC);
return listMSC;
}
Flex Result Handler
var ReturnData:ArrayColelction = event.result as ArrayCollection;
When I debug and Watch for Expression ReturnData I get the following
ReturnData
[0]
column1 "1"
column2 "2"
Though the process is all correct and the values too are all correct, the names of the objects of 0 index of ReturnData is changed from Column1 to column1 and Column2 to column2.
I think this done by Flex AMF Data Serilization. How could it be prevented so that I can get Coulmn1 as Column1 etc. If not what is the concept behind it.
Thanks in Advance.
Yes, this is because BlazeDS uses Java Bean naming convention.
First of all, in Java you don’t name class’s members (fields, methods) starting with a capital letter.
Second, it is a good practice to follow encapsulation principles and make your fields private and use getters/setters to mutate them.
In you case this would be like this:
But in general: DON’T start variables with a capital letter.