mdoberenz wrote:

> I'm pretty sure this is possible, but I can't get it to work.
>
> I'm wanting to typecast a generic object that gets returned by a
> WebService call into a VO, but I'm having some issues.
> Say I have a VO of the following:
>
> public class TestVO{
> [Bindable] public var i_test:int;
> [Bindable] public var s_test:String;
> [Bindable] public var o_test:Object;
> }
>
> Then I get an object back from a WebService call that has a similar
> structure, can't I just do the following?:
>
> var typeCastTry:TestVO = RETURN_OBJ as TestVO;
>
> When I do this, typeCastTry gets set to null.

Yeah, this is the tradeoff for not using FDS. As I see this, Flex is 
unaware of the types passed thru SOAP from webservices. There is no 
automatic mapping/casting types on-the-fly. Flex could try an automatic
mapping, but in the end, there will be more complex situations, where
some kind of external xml mapping is needed.

I'm struggling with good solution for this one too. What I currently 
have is an PO object, which I call Perspective Object, which is some 
kind of mature object, created from raw VO (having public fields, for 
example. VO on the other hand has privates). There you could specify 
such methods as :

public static function transformFromObject(object:Object):BookPO {
        return new BookPO(object.id, object.name, object.author);       
}
        
public static function 
transformCollection(collection:ArrayCollection):ArrayCollection {

        var col:ArrayCollection = new ArrayCollection();
        var cur:IViewCursor = collection.createCursor();
        while (! cur.afterLast) {
         var book:BookPO = transformFromObject(cur.current);
         col.addItem(book);
         cur.moveNext();
        }
                
         return col;
}

But I feel that there is something not right with setting properties by 
hand. I've found this :
http://coldfusion.sys-con.com/read/264726.htm
on Sys-CON, but the solution provided there is even more unclear for me.

And oh, the isn't the RETURN_OBJ always an ArrayCollection of Objects?
(event.result, that is).

Hope this helps a little bit.


-- 
| Sebastian Zarzycki / rat[tkin]
| [EMAIL PROTECTED]
| i'm a little lost in this postmodern space






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to