Hi,
Is it possible to have a generically typed List
(e.g.List<MyType>)
instance variable on my object serialized to an
ArrayCollection of
MyType objects in the corresponding AS object? I've struggled
for days
on this and would greatly appreciate if anyone could tell me
if it is
possible.
For example, I have a Java DTO object (AccountProfileDTO)
that
assembles various objects related to a user for transfer to
the
client (see code below). In Flex, I call a remote Java method
that
returns an AccountProfileDTO object.
The Java method correctly populates the user (User) and
userMedications (List<UserMedication>) instance
variables on the DTO.
However, when I examine the resulting AccountProfileDTO in
Flex, I see
the user field is correctly populated but the userMedications
ArrayCollection is populated with AS Object instances instead
of
UserMedication instances. The Object instances contain the
correct
properties and values, but I would like to have the Objects
strongly
types as UserMedication instances just like the Java object.
How do I do this, or is it not possible?
Please see my source code below. I'm using Tomcat + Spring +
Flex3. I have no idea where to find the "Attach Code" options, so I
apologize if the code is hard to read.
Thanks,
Tom
----- AccountProfileDTO (Java) --------------
package com.ghs.dto;
import java.util.List;
import com.ghs.model.User;
import com.ghs.model.UserMedication;
public class AccountProfileDTO {
private User user;
private List<UserMedication> userMedications;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public List<UserMedication> getUserMedications() {
return userMedications;
}
public void setUserMedications(List<UserMedication>
userMedications) {
this.userMedications = userMedications;
}
}
----- AccountProfileDTO (ActionScript) --------------
package com.ghs.dto
{
import com.ghs.model.*;
import com.ghs.dto.*;
import mx.collections.*;
[Bindable]
[RemoteClass(alias="com.ghs.dto.AccountProfileDTO")]
public class AccountProfileDTO {
public var user:User;
public var userType:UserType;
public var userAuthorities:ArrayCollection;
public var userMedications:ArrayCollection;
public var lastModUser:User;
public var lastModUserType:UserType;
public var lastModProvider:Provider;
}
}
---------------- UserMedication (Java) -------------------
package com.ghs.model;
public class UserMedicationKey {
private String medication;
private Long userId;
public String getMedication() {
return medication;
}
public void setMedication(String medication) {
this.medication = medication;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
}
---------------- UserMedication (ActionScript)
-------------------
package com.ghs.model
{
import com.ghs.model.*;
import com.ghs.dto.*;
import mx.collections.*;
[Bindable]
[RemoteClass(alias="com.ghs.model.UserMedication")]
public class UserMedication extends UserMedicationKey {
public var lastModBy:Number;
public var lastModDate:Date;
public var frequency:String;
public var dateStarted:Date;
public var strength:String;
}
}
--------------UserMedicationKey (Java) ---------------------
package com.ghs.model;
public class UserMedication extends UserMedicationKey {
private String strength;
private String frequency;
public String getStrength() {
return strength;
}
public void setStrength(String strength) {
this.strength = strength;
}
public String getFrequency() {
return frequency;
}
public void setFrequency(String frequency) {
this.frequency = frequency;
}
}
--------------UserMedicationKey (ActionScript)
---------------------
package com.ghs.model
{
import com.ghs.model.*;
import com.ghs.dto.*;
import mx.collections.*;
[Bindable]
[RemoteClass(alias="com.ghs.model.UserMedicationKey")]
public class UserMedicationKey {
public var userId:Number;
public var medication:String;
}
}