Hi, i'm building a project with Cairngorm 2.1 and Flex
2. But i'm getting type coercion error trying to store
a element of server result (array of objects using
weborb) at a variable called "selectedItem". I
firstly, store as Array and convert it to a
ICollectionView to sort it, but still can't convert my
object type from server to my VO. Can anybody help me
please?

Following, the codes:
//GetFabricaCommand.as, function result()
public function result( event : Object  ) : void
{                               
var resultado : ArrayCollection = new ArrayCollection(
event.result as Array );
var fabricas : ICollectionView =
ICollectionView(resultado);
var model : AtacadoMoveisModelLocator =
AtacadoMoveisModelLocator.getInstance();

// sort the data
var sort :Sort = new Sort();
sort.fields = [ new SortField( "nome", true ) ];
fabricas.sort = sort;
fabricas.refresh();
           
//model.selectedItem =
FabricaVO(resultado.getItemAt(0)); //this doesnt works
model.selectedItem = FabricaVO(fabricas[ 0 ]);
model.fabricas = fabricas; //this works
}
//End of result function

Now, the VO (FabricaVO.as):
package com.adobe.cairngorm.atacadomoveis.vo
{
        import com.adobe.cairngorm.vo.IValueObject;
        import
com.adobe.cairngorm.atacadomoveis.util.Comparable;
                 
        
        
        public class FabricaVO implements IValueObject,
Comparable 
        {
                public function get identifier() : String
                {
                        return String( id_fabrica );
                }
        
                public function toString() : String
                {
                    var s : String = "FabricaVO[id=2];";
                    return s;
                }
                [Bindable]
        public var id_fabrica : Number;
        
                [Bindable]
        public var nome : String;
        
        [Bindable]
        public var descricao : String;
        
        [Bindable]
        public var logo : String;
        
        [Bindable]
        public var data_cadastro : String;
        
        [Bindable]
        public var login : String;
        
        [Bindable]
        public var senha : String;
        
        [Bindable]
        public var endereco : String;
        
        [Bindable]
        public var cidade : String;
        
        [Bindable]
        public var telefone : String;
        
        [Bindable]
        public var email : String;
        
        [Bindable]
        public var cnpj : String;
        
        [Bindable]
        public var ranking : Number;
        
        [Bindable]
        public var removido : Boolean;

        }

}

Can anybody give me some light?
Thanks ;]


      Abra sua conta no Yahoo! Mail, o único sem limite de espaço para 
armazenamento!
http://br.mail.yahoo.com/

Reply via email to