Announcement Announcement Module
No announcement yet.
Error when implementing Enums using Actionscript 3 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error when implementing Enums using Actionscript 3

    Ours is a Flex/Parsley/Blazeds/Spring project & I'm trying to implement java Enums in Actionscript3 and all I have to do is to send the Enum value to Spring service method.

    The Java Enum Code (this is generated from XSD)

    public enum ReferenceLookupType {

    private final String value;

    private ReferenceLookupType(String value) {
    this.value = value;

    public String toString() {
    return value;

    public static ReferenceLookupType convert(String value) {
    for (ReferenceLookupType inst : values()) {
    if (inst.toString().equals(value)) {
    return inst;
    return null;
    The Actionscript Enum is:

    package {

    [RemoteClass(alias="com.datacollection.model.Refere nceLookupType")]
    public final class ReferenceLookupType {

    public static const PATIENT_VISIT_TYPE:ReferenceLookupType = new ReferenceLookupType("PATIENT_VISIT_TYPE");
    public static const PATIENT_STATUS:ReferenceLookupType = new ReferenceLookupType("PATIENT_STATUS");
    public static const PATIENT_VISIT_INVALID_REASON:ReferenceLookupType = new ReferenceLookupType("PATIENT_VISIT_INVALID_REASON" );
    public static const LIPID_PREFILLED_CODE:ReferenceLookupType = new ReferenceLookupType("LIPID_PREFILLED_CODE");

    private var _value:String;

    public function ReferenceLookupType(value:String) : void
    _value = value;

    public function toString():String
    return _value;
    In the mxml code:

    private var refLookupType:ReferenceLookupType = ReferenceLookupType.LIPID_PREFILLED_CODE;

    dispatcher(new ReferenceDataMessage(refLookupType, "RefData"));
    The Error I'm getting is:

    "Unable to create a new instance of type 'gov.hhs.cms.ehrds.datacollection.model.ReferenceL ookupType'." faultCode="Client.Message.Encoding" faultDetail="Types cannot be instantiated without a public, no arguments constructor."

    [RPC Fault faultString="Unable to create a new instance of type 'com.datacollection.model.ReferenceLookupType'." faultCode="Client.Message.Encoding" faultDetail="Types cannot be instantiated without a public, no arguments constructor."]
    at mx.rpc::AbstractInvoker/[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\Ab]
    at mx.rpc::Responder/fault()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\Re]
    at mx.rpc::AsyncRequest/fault()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\As]
    at NetConnectionMessageResponder/statusHandler()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messag ing\channels\]
    at mx.messaging::MessageResponder/status()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messag ing\]

    Can you please help in what I'm missing here and on how to implement Enums in Actionscript the right way.


  • #2
    Not quite sure, but as far as I know, Java enums get mapped as Strings in AS.

    Means your AS-Enum must look like this (or similar):
    public class ReferenceLookupType {
    public static const PATIENT_VISIT_TYPE:String = "PATIENT_VISIT_TYPE"; 

    Actually, if I got it right, this has nothing to do with Spring Actionscript. But actually (I think) AS3 Commons provides an Enum class. Not sure if you can also use this implementation for BlazeDS mapping...


    • #3

      this is indeed not a Spring ActionScript issue, but I'll point out some things we did in order to get typed enums between our server and client.

      Check out this post ( and comments on the Adobe Jira. It contains an EnumProxy class that you need to register as a proxy in BlazeDS. You can do this in a static block as mentioned in the comments, or you can do the registration in your Java Spring context by creating a MethodInvokingFactoryBean, as we did.

      The nice thing is that this will work with the AS3Commons Enum class. The only thing you need to do, is change the value of the EnumProxy.ACTION_SCRIPT_VALUE_NAME variable to "name" instead of "val".

      Then specify a remote class alias for your client enums and you should be good to go.