BlazeDS serializing Enum as Object instead of String

Hi,
we're having a problem with the serialization of our Java enums to Actionscript strings. The documentation says that by default, BlazeDS serializes an enum to an actionscript string.
We only get [object Object] however and if I create a fake enum class in Actionscript we get [object enumName] as a result. The property is of enum type in the Java class and of String type in the actionscript class.
I've looked around for solutions on the web but all I can find are examples to provide you with some kind of Actionscript "enum" functionality, while all we want is the default functionality of BlazeDS to work.
The classes are:
Java DocumentSearchResultTypeEnum:
package be.brail.a327.model.enumeration;
* Enum with the type of result: folder or document
public enum DocumentSearchResultTypeEnum {
    FOLDER, DOCUMENT
Java DocumentSearchResultDto:
package be.brail.a327.model.dto.search;
import org.apache.commons.lang.math.NumberUtils;
import be.brail.a327.model.dto.AbstractValidityDto;
import be.brail.a327.model.dto.annotation.RiaNumber;
import be.brail.a327.model.enumeration.DocumentSearchResultTypeEnum;
* Result of a search for documents
public class DocumentSearchResultDto extends AbstractValidityDto {
    private static final long serialVersionUID = -4645818109238956407L;
    @RiaNumber
    private String parentId;
    private String description;
    private DocumentSearchResultTypeEnum type;
     * {@inheritDoc}
     * @see be.brail.a327.model.dto.AbstractDto#getStringInfo()
    @Override
    public String getStringInfo() {
        StringBuilder sb = new StringBuilder();
        sb.append("[id=");
        sb.append(this.getId());
        sb.append("[parentId=");
        sb.append(this.getParentId());
        sb.append("[type=");
        sb.append(this.getType().toString());
        sb.append("[description=");
        sb.append(this.getDescription());
        sb.append("]");
        return sb.toString();
     * Set the description.
     * @return the description
    public void setDescription(String description) {
        this.description = description;
     * Get the description.
     * @return the description
    public String getDescription() {
        return description;
     * Set the parentId.
     * @return the parentId
    public final void setParentId(String parentId) {
        this.parentId = parentId;
     * Get the parentId.
     * @return the parentId
    public final String getParentId() {
        return this.parentId;
     * Set the type.
     * @return the type
    public void setType(final DocumentSearchResultTypeEnum type) {
        this.type = type;
     * Get the type.
     * @return the type
    public DocumentSearchResultTypeEnum getType() {
        return type;
     * Overrides the equals
     * @see java.lang.Object#equals(java.lang.Object)
    public boolean equals(Object o) {
        if (o instanceof DocumentSearchResultDto
                && NumberUtils.toLong(((DocumentSearchResultDto) o).getId()) == NumberUtils.toLong(this.getId())) {
            return true;
        } else {
            return false;
Actionscript DocumentSearchResultTypeEnum:
package be.brail.a327.console.model.enum
    [RemoteClass(alias= "be.brail.a327.model.enumeration.DocumentSearchResultTypeEnum")]
    public class DocumentSearchResultTypeEnum
        public static const FOLDER:String = "FOLDER";
        public static const DOCUMENT:String = "DOCUMENT";
Actionscript DocumentSearchResultDto:
package be.brail.a327.console.model.dto
    import be.brail.a327.console.model.enum.DocumentSearchResultTypeEnum;
    import be.brail.a327.dto.AbstractValidityDto;
    import mx.collections.ArrayCollection;
    [RemoteClass(alias = "be.brail.a327.model.dto.search.DocumentSearchResultDto")]
    public class DocumentSearchResultDto extends AbstractValidityDto
        public var parentId:String;
        public var description:String;
        public var type:String;
        [Transient]
        public var isBranch:Boolean = true;
        [Transient]
        public var children:ArrayCollection;
Type in DocumentSearchResultDto is always "[object Object]" (or "[object DocumentSearchResultTypeEnum]" if we map the DocumentSearchResultTypeEnum class).
What are we doing wrong?
Thx in advance!

Hey
just have a look at the Date-Class there is the parse()
method which is static and the parameter is a string.
Cheers
Dietmar

Similar Messages

  • (261718088) Q: Can you use xm:multiple with Objects other than String?

    Q: Can you use xm:multiple with Objects other than Strings?
    <br>
    A: You bet. Attached find a text file with some code from the example I showed
    today, a version of the multipleSayHiTo() method that has a parameter of an Array
    of Person objects rather than a parameter of an Array of Strings. The code within
    the text file comes from the Greeting.jws file (the Greeting Web Service).
    [multiple.txt]

    So you are saying that the recovery discs I made do include the copy of windows that was originally installed?
    Absolutely! They will restore the hard disk to its original out-of-the-box contents. Follow the instructions in the section Restoring from recovery DVDs/media, which begins on p. 73 of the User's Guide.
       Satellite A660 Series User’s Guide
    maybe i can make a deal with wd to have them swap this drive out for the BEKT instead...
    That would be a good idea in any case.
    As I said, the 10-fc12-045d error would not be due to the drive's being AFT, but more likely the discs are not being read properly. New discs can be obtained from Toshiba. Scroll down to Get Recovery Media here
    -Jerry

  • How do i convert an object into a string?

    has said above, im trying to convert a object to a string.
    here is what i ahve so far:
    Object nodeInfo = node.getUserObject()

    RTFM
    Object o =...
    String str = o.toString();

  • Can you create an object from a string

    I have been working on creating a dynamic form, creating the
    form items from an xml file. I am getting very close to conquering
    this task. I will share it when it's complete.
    However, I am stuck at the moment trying to create an object
    from a string. For example, if the xml item is an HBox I want to
    create an HBox. Like this: parentObject = new arrayOfFormItems[
    index ]..type ()
    This isn't working. First, is this possible using some syntax
    I am unaware of in Flex? I don't want to use a large if or case
    statement if possible.
    Thanks in advance for your help!

    Thank you very much. Indeed that did solve the one problem. I
    missed the casting as a Display Object. That is awesome!
    I do still however, have to instantiate one of every item I
    want to dynamically create or I get the following error when I try
    to create a dynamic object that I have not instantiated before.
    ReferenceError: Error #1065: Variable HBox is not defined.
    at global/flash.utils::getDefinitionByName()
    at MyForm/buildForm()
    at DynamicForm/::onComplete()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    I read that you have no choice but to instantiate one of each
    type to force the linker to link the code for that class into the
    .swf. Unless you know another way to force it.
    This is what I have in my Application mxml to get it to work:
    <mx:HBox>
    <mx:Text visible="false"/>
    <mx:TextArea visible="false"/>
    <mx:TextInput visible="false"/>
    <mx:DateField visible="false"/>
    </mx:HBox>
    And those are the types I'm using to test with. . . I will
    have to add all the others I want to use as well . . .

  • Setting the name of a new object from a string

    Is there anyway I can set the object name of a newly created
    object from a string?
    eg.
    (the code below generates a compile time error on the
    variable declaration)
    public function addText(newTxt:String, txt:String,
    format:TextFormat):void {
    var
    this[newTxt]:TextField = new TextField();
    this[newTxt].autoSize = TextFieldAutoSize.LEFT;
    this[newTxt].background = true;
    this[newTxt].border = true;
    this[newTxt].defaultTextFormat = format;
    this[newTxt].text = txt;
    addChild(this[newTxt]);
    called using>
    addText("mytxt", "test text", format);
    I could then reference the object later on without using
    array notation using mytxt.border = false; for example
    There are many a time when I want to set the name of a new
    object from a string.
    In this example I have a function that adds a new text object
    to a sprite.
    The problem is, if I call the function more than once then
    two textfield objects will exist, both with the same name. (either
    that or the old one will be overwritten).
    I need a way of setting the name of the textfield object from
    a string.
    using
    var this[newTxt]:TextField = new TextField()
    does not work, If I take the "var" keyword away it thinks it
    a property of the class not an object.
    resulting in >
    ReferenceError: Error #1056: Cannot create property newTxt on
    Box.
    There must be a way somehow to declare a variable that has
    the name that it will take represented in a string.
    Any help would be most welcome
    Thanks

    Using:
    var this[newTxt]:TextField = new TextField()
    is the right approach.
    You can either incrment an instance variable so that the name
    is unique:
    newTxt = "MyName" + _globalCounter;
    var this[newTxt]:TextField = new TextField();
    globalCounter ++;
    Or store the references in an array:
    _globalArray.push(new TextField());
    Tracy

  • Object creation of string

    Hello
    Please tell me what is the difference between these two object creation of string.
    String str = new String("Hello");.
    String str="Hello";
    Thanks.

    RGEO wrote:
    hello,
    Is the string pool is part of a heap? Huh? I suppose yes, you could regard the String pool as part of the heap... but (I guess) that interned String objects would be placed directly into the permanent generation, which is not garbage collected... and therefore I don't really think of the permanent generation as part of the heap (except when tuning heap allocations)... but I think I'm talking over your noob head here, yes... and so to the noob-stuff.
    If you get bored you might like to scan (for now) http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#generations ... and come back to it in a couple of years time (when every second word isn't new and baffling to you;-)
    jvm what will do when he encounter the following code,
    String s1 = new String ("hello");The VM will:
    1. Create a new String object, and then
    2. copy the characters 'h','e','l','l','o' from the interned String "hello" to the new String,
    3. and then assign a reference to the new String to variable s1.
    Note that the result is subtley different from String s1 = "hello", which just does step 3... it assigns a reference to the existing interned String object "hello" to the variable s1... it does not create and "populate" a new String object.
    Try this just for fun... what is the output of the following program? Why?
    package forums;
    public class StringEquals
      public static void main(String[] args) {
        try {
          String a = "Hello";
          String b = "Hello";
          System.out.println("a==b is "+(a==b));
          String c = new String("Hello");
          System.out.println("a==c is "+(a==c));
        } catch (Exception e) {
          e.printStackTrace();
    }Now, what's the correct way to evaluate equality of String objects in Java?
    HTH. Cheers. Keith.

  • Using domain object instead of generated ones?

    I'm using NetBeans, and I'm curious if there's a way that we can use our domain objects with the web service calls rather than the empty stubs generated by wsgen?
    wsgen creates the skeletal client classes, as well as an ObjectFactory that returns instances of those classes. I imagine I could modify ObjectFactory to return our domain objects instead, but then we'd be breaking with wsgen.
    Is there a better solution to this?
    Thanx!

    You can associate a Virtual Host to the loopback IP address 127.0.0.1 read about Virtual Hosts here: http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
    But with the above configuration alone you can access your app via http://somedomainname.com only on your local machine, no one else on the internet will see it.

  • How to create a Document object from a string.

    If I use the following code, the input String cannot contain "\n", otherwise, it generates errors.
    in the following code, inputXMLString is a String object that has xml content.
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(inputXMLString)));          How can I create a Document object from a string with "\n" in the string?
    Thanks.

    If I use the following code, the input String cannot
    contain "\n", otherwise, it generates errors.That's going to be a huge surprise to thousands of people who process XML containing newline characters every day without errors.
    Perhaps your newline characters are in the middle of element names, or something else that causes your XML to be not well-formed. I'm just guessing here, though, because you didn't say what errors you were getting.

  • Convert an Object into a String

    Good day to everyone. I am trying to do a little coding in which a user will input his desired username. I want to check the database if the desired username of the current user is existing, so there'll be no duplication. I'm using JPA for the model and JSF for the controller and view.
    Here's my Model.
    @Entity
    public class WebUser implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        private String lastName;
        private String firstName;
        private String middleName;
        private String username;
        private String password;
        public Long getId() {
            return id;
        public void setId(Long id) {
            this.id = id;
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (id != null ? id.hashCode() : 0);
            return hash;
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof WebUser)) {
                return false;
            WebUser other = (WebUser) object;
            if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                return false;
            return true;
        @Override
        public String toString() {
            return "web.model.WebUser[id=" + id + "]";
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getMiddleName() {
            return middleName;
        public void setMiddleName(String middleName) {
            this.middleName = middleName;
        public String getUsername() {
            return username;
        public void setUsername(String username) {
            this.username = username;
        public String getPassword() {
            return password;
        public void setPassword(String password) {
            this.password = password;
    }The controller and jsp are auto-generated from Netbeans. My question is, how will I convert the 'WebUser' object into a String so I can compare the value from input text to the value in the database?
    Here is my validation method inside WebUserController.java
    public void validateUsername(FacesContext facesContext, UIComponent component, Object value) throws ValidatorException {
            String newUsername = (String) value;
            System.out.println("new user name: " +newUsername);
            System.out.println("component: " +component);
            int webUserSize;
            StringBuffer sb = new StringBuffer();
            //webUsers.toString();
            if ((webUsers == null) || (webUsers != null)) {
                System.out.println("web users null");
                List<WebUser> allWebUsers = getWebUsers();
                webUserSize = allWebUsers.size();
                System.out.println("all web users: " +allWebUsers);
                System.out.println("size " +webUserSize);
                for(int i=1; i<=webUserSize; ++i) {
                    sb.append(allWebUsers);
                    System.out.println("username: " +sb.append(allWebUsers));
            }Honestly I'm new to java and having a hard time with this one. Hope someone can help me. Thanks a lot.
    I know my code is a mess. :(

    Thanks for the help guys! I used the "unique constraint" annotation of JPA and my problem is solved.
    Here's the code:
    @Entity
    @Table(
        name="WebUser",
        uniqueConstraints={@UniqueConstraint(columnNames={"username"})}
    public class WebUser implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        private String lastName;
        private String firstName;
        private String middleName;
        private String username;
        private String password;
        public Long getId() {
            return id;
        public void setId(Long id) {
            this.id = id;
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (id != null ? id.hashCode() : 0);
            return hash;
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof WebUser)) {
                return false;
            WebUser other = (WebUser) object;
            if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                return false;
            return true;
        @Override
        public String toString() {
            //return "web.model.WebUser[id=" + id + "]";
            return "web.model.User[username=" + username +"]";
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getMiddleName() {
            return middleName;
        public void setMiddleName(String middleName) {
            this.middleName = middleName;
        public String getUsername() {
            return username;
        public void setUsername(String username) {
            this.username = username;
        public String getPassword() {
            return password;
        public void setPassword(String password) {
            this.password = password;
    }Thanks again guys!

  • Cast Object Array to String Array.

    When I try to cast an object array to string array an exception is thrown. How do I go about doing it?
    Vector temp = new Vector();
    Object[] array = temp.toArray();
    String[] nonterms;                              
    nonterms = (String[])array;
    Thanks,
    Ally

    Try this
    import java.util.Vector;
    public class Test
         public static void main(String args[]) throws Exception
              Vector v = new Vector();
              v.add("a");
              v.add("b");
              v.add("c");
              Object[] terms = v.toArray();
              for(int i = 0; i < terms.length; i++)
                   System.out.println((String)terms);
    Raghu

  • What is this - Object[] x = {new String[]{"a","b"}};

    What is the meaning of this -
    Object[] x = {new String[]{"a","b"}};
    I have a function which takes Object[] as a argument. And I have data structure like this -
    Name = Zoolander
    Name = Hansel
    Name = Mugatu
    I am not interested in the Name part. This has to be converted to - Object[] x = {new String[]{"a","b"}}
    It works if I hard code the values like this -
    Object[] x = {new String[]{"Zoolander","Hansel","Mugatu"};
    Thanks in advance

    Don't crosspost, please.

  • Transporting LSMW single object instead of entire project

    Dear Experts,
    When I am selecting LSMW object and then selecting Generate Change Request from Extras, then it is creating Transport request for entire project instead of a single object.
    How can i transport single LSMW Object instead of entire project.
    Please help me.
    Thanks & Regards
    Rangababu

    Hi,
    when you are on the first screen of LSMW, can't you go via Extras->Export Project. Then you can select on detailed level what you want to export to a flat file.
    On your other system you can import this flat file (and you can even rename stuff while importing). Not sure, but it might be that the import functionality is blocked on your other system. If not, I think this is the way to go.

  • Possible to create an object from a String?

    Hi,
    is is somehow at all possible to create an object from a String ?
    If we have etc.
    String txt = "Carrot()";
    Is it then possible to somehow cast that String and interpret it as a class type that it should make an object of ?
    Like
    new txt; - would then give me the same as new Carrot(); ?
    Hope you understand what i mean.
    Martin From... :-)

    Class.forName("some.package.Carrot");

  • Just bought and iPad Air 1 sell send me serial number MD786LL/A instead of MD786B/A.  I believe LL/A is USA - can this new iPad I have received work in the United Kingdom or should I send it back??

    Just bought and iPad Air 1 sell send me serial number MD786LL/A instead of MD786B/A.  I believe LL/A is USA - can this new iPad I have received work in the United Kingdom or should I send it back??

    If this is a Wifi only unit, it will work just fine in the UK.

  • How to pass serialized object and the string through the socket together?

    I have an application which listens on a port and I usually read string lines from it. Now I want to pass serialised object through it , plus I should indicate (using some string like "object coming") tht the following packet is a serialized object.

    Since Strings are serializable you could just send a stream of serialized objects then you don't have to know anything about the format.

Maybe you are looking for

  • Tv to computer display

    I have connected my tv to my computor and my tv has the background only showing where am i going wrong

  • Auto Date/Time stamp required for Numbers 3.1

    I would like to automatically add a Date/Time stamp to the last column's cell, when a person's name is selected from the pop-up menu in Column C. As a number of different people will be using the spreadsheet, I'd prefer not to have a keyboard short c

  • Modem with mac & PC

    I am trying to share a cable modem with someone who has a PC. My sister doesn't have wireless internet, she uses a cable modem and a CAT5 cable. When I separate the CAT5 from her computer and try to plug in mine, I am unable to connect to the interne

  • A4 top and bottom margins too big - Pages 08

    I am using the pages 08 in A4 document and the margin setup for the top margin is 0,35cm and bottom margins are 0,85 cm but in the print-out they are 3,5 cm and 4,5 cm. Header and footer are off

  • IPhone 4 uses 6gb of space for 2gb of photos

    I have just synced 2gbof photos from my PC to my iPhone 4 but iTunes is showing that photos is using 6.1gb of space. Why would this be and how do I resolve? I have the iPhone 4 with os 4.1 on my laptop I have win 7 with iTunes 10