Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Enum JSTranslater problem

$
0
0
1. SmartClient Version: v9.1p_2014-04-08/Pro Development Only (built 2014-04-08)

2. All browsers (f.e. Chrome Version 0.0.2214.111 m)

3. When object is sent from server to UI as a data of DMI callback, its JSON view differs in case enum is composed in it.

Code:

public enum DataType {

        A("a", "a"),
        B("b", "a");
        private String s1;
        private String s2;

        DataType(String s1, String s2) {
                this.s1 = s1;
                this.s2 = s2;
        }

        public String getS1() {
                return s1;
        }
       
        public String getS2() {
                return s2;
        }

        public boolean isSupported() {
                return s1.equals(this);
        }
}

public enum FieldType {

        A("a", "a") {
              @Override
              public boolean isSupported() {
                return true;
              }
        },
        B("b", "a") {
              @Override
              public boolean isSupported() {
                return false;
              }
        };
        private String s1;
          private String s2;

        DataType(String s1, String s2) {
                this.s1 = s1;
                this.s2 = s2;
        }

        public String getS1() {
                return s1;
        }
       
        public String getS2() {
                return s2;
        }

        public abstract boolean isSupported;

}

public class CustomDto implements Serializable {
       
        private static final long serialVersionUID = 1L;
       
        private FieldType fieldType;
        private DataType dataType;

        public FieldType getFieldType() {
                return fieldType;
        }

        public void setFieldType (FieldType ft) {
                this.fieldType = ft;
        }

        public DataType getDataType() {
                return dataType;
        }

        public void setDataType (DataType dt) {
                this.dataType= dt;
        }
}

result in UI:
Code:

{
        dataType: "A",
        fieldType: {
                class: "com. ... .FieldType",
                s1: "a",
                s2: "a",
                supported: true
        }
}

however I expect the same behavior:
Code:

{
        dataType: "A",
        fieldType: "A"
}


My question is: how can I get the same result by passing enum to UI?

Viewing all articles
Browse latest Browse all 4756

Trending Articles