Hi there.
I am running the latest code from SVN and I am having the following problem.

On the java side :
Class R5Account has an ArrayCollection of entries (these are R5AccountEntries).

When this gets passed over the wire, I get the following error on the flex side :

TypeError: Error #1034: Type Coercion failed: cannot convert [EMAIL PROTECTED] to mx.collections.ArrayCollection.

The User and Account classes deserialise properly, the AccountEntries does not.

Ideally I want Account Class to have an ArrayCollection of AccountEntries.

Any pointers ?

Thanx
Thys de Wet

----------------------------------------------------- Java Code -------------------------------------------------------------------
public class User {
    public String name;
    public String password;
    public R5Account account;
   
    public User(){
        this.account = new R5Account();
    }
   
    public R5Account getAccount() {
        if ( account == null){
            setAccount(new R5Account());
        }
        return account;
    }
    public void setAccount(R5Account account) {
        this.account = account;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    } 
}


import java.math.BigDecimal;

import org.red5.compatibility.flex.messaging.io.ArrayCollection;


public class R5Account implements java.io.Serializable{
   
    public BigDecimal balance;
    public ArrayCollection entries;
   
    public ArrayCollection getEntries() {
        return entries;
    }
    public void setEntries(ArrayCollection entries) {
        this.entries = entries;
    }
    public BigDecimal getBalance() {
        return balance;
    }
    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    } 
}



import java.math.BigDecimal;

import com.playlogix.chesschat.account.AccountEntry;

public class R5AccountEntry implements java.io.Serializable {
    public BigDecimal runningBalance;
    public String description;
    public BigDecimal amount;
   
    public R5AccountEntry(AccountEntry entry) {
        this.runningBalance = entry.getRunningBalance();
        this.description = entry.getReference();
        this.amount = entry.getAmount();
    }
    public BigDecimal getAmount() {
        return amount;
    }
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public BigDecimal getRunningBalance() {
        return runningBalance;
    }
    public void setRunningBalance(BigDecimal runningBalance) {
        this.runningBalance = runningBalance;
    }

}


Snippet that send User back :

                Set<AccountEntry> entries = user.getDefaultAccount().getAccountEntries();
                ArrayCollection r5accs = new ArrayCollection();
                for (AccountEntry accEntry : entries) {
                    r5accs.add(new R5AccountEntry(accEntry));
                }
                user1.getAccount().setEntries(r5accs);
                return user1;



------------------------------------------------ActionScript Classes ----------------------------------------------

package com
{
    import mx.collections.ArrayCollection;
   
    [RemoteClass(alias="com.playlogix.red5.R5Account")]
    public class Account
    {
        public var balance:Number;
        public var entries:ArrayCollection;
    }
}



package com
{
    [Managed]
    [RemoteClass(alias="com.playlogix.red5.R5AccountEntry")]
    public class AccountEntry
    {
        public var runningBalance:Number;
        public var description:String;
        public var amount:Number;
    }
}


package com
{
    [RemoteClass(alias="com.playlogix.red5.User")]
    public class User
    {
        public var name:String;
        public var password:String;
        public var account:Account;
    }
}







_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to