In the example code below I don't even see any RemoteObject metadata.
Also, is the dg's dataprovider of ArrayElementType EmployeeVO? It's
unclear.  It's not a question of data types alone - the metadata must be
present for the conversion to work correctly. 

        -----Original Message-----
        From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui
        Sent: Monday, June 09, 2008 11:09 PM
        To: [email protected]
        Subject: RE: [flexcoders] new to VO's, why won't this cast?
        
        

        If you dg doesn't contain the same VO's you think you got from
the server, I'd double check the [RemoteClass] metadata.

         

        
________________________________


        From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Derrick Anderson
        Sent: Monday, June 09, 2008 2:12 PM
        To: [email protected]
        Subject: Re: [flexcoders] new to VO's, why won't this cast?

         

        coldfusion, but i don't think it matters- i'm trying to take an
actionscript object (the selectedItem of a datagrid) and cast it to
another actionscript object (my VO).  i suspected the mx_internal_uid
property on the list item is messing me up, it's the only property that
comes into the VO from the datagrid that the VO does not have- so i got
to googling.
        
        http://blog.smashedapples.com/2008/02/my-boring-base.html
<http://blog.smashedapples.com/2008/02/my-boring-base.html> 
        
        so now i have a base VO class that all my other VO's extend, and
in this superclass I loop over properties and remove that one, and now-
it all works fine.
        
        thanks,
        d.
        
        
        

        On Mon, Jun 9, 2008 at 4:30 PM, Sherif Abdou
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote:

        well are you using ColdFusion? AMFPHP?

        ----- Original Message ----
        From: Derrick Anderson <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >
        To: [email protected]
<mailto:[email protected]> 

        Sent: Monday, June 9, 2008 2:36:26 PM
        Subject: Re: [flexcoders] new to VO's, why won't this cast?

        i do get the employee list from a database, and I tried putting
RemoteClass metadata on the VO class with an alias- no luck- same error.
        
        d.

        On Mon, Jun 9, 2008 at 3:26 PM, Sherif Abdou <[EMAIL PROTECTED]
com <mailto:[EMAIL PROTECTED]> > wrote:

                well are you getting this from a Database, if you are
then you may be able to use the RemoteClass metadata?

                ----- Original Message ----
                From: Derrick Anderson <no.way.this. is.in.use@
gmail.com <mailto:[EMAIL PROTECTED]> >

                To: [EMAIL PROTECTED] ups.com
<mailto:[email protected]> 

                Sent: Monday, June 9, 2008 2:12:48 PM
                Subject: Re: [flexcoders] new to VO's, why won't this
cast?

                actually, the link was http://casario. blogs.com/
mmworld/2007/ 04/casting_ a_datag.html
<http://casario.blogs.com/mmworld/2007/04/casting_a_datag.html> 
                
                it's a very simple example of exactly what I'm trying to
do.
                
                d.

                On Mon, Jun 9, 2008 at 3:09 PM, Derrick Anderson
<no.way.this. is.in.use@ gmail.com
<mailto:[EMAIL PROTECTED]> > wrote:

                        i've seen other examples of this working..
                        
                        http://casario. blogs.com/ mmworld/2007/
04/passing_ actions.html
<http://casario.blogs.com/mmworld/2007/04/passing_actions.html> 
                        
                        i tried setting it a property at a time and that
of course works- but i'll have to write much more code and it will be
harder to maintain.
                        
                        thanks,
                        d.

                         

                        On Mon, Jun 9, 2008 at 2:59 PM, Sherif Abdou
<[EMAIL PROTECTED] com <mailto:[EMAIL PROTECTED]> > wrote:

                                Ok i think you can't do that since I am
looking at Adobe <http://www.adobe.com/>  Flex Professional 2.0 wrox
book and they have a similar example and what they did was
                                EmployeeVO.employee ID =
objectName.employee ID;

                                ----- Original Message ----
                                From: Derrick Anderson <no.way.this.
is.in.use@ gmail.com <mailto:[EMAIL PROTECTED]> >
                                To: [EMAIL PROTECTED] ups.com
<mailto:[email protected]> 

                                Sent: Monday, June 9, 2008 1:51:08 PM
                                Subject: Re: [flexcoders] new to VO's,
why won't this cast?

                                ok, here is EmployeeVO.as
                                
                                package com.winn.vo
                                {
                                    [Bindable]
                                    public class EmployeeVO
                                    {
                                        public var employeeID:uint;
                                        public var roleID:Number;
                                        public var employeeTypeID:
Number;
                                        public var employeeStatusID:
Number;
                                        
                                    }
                                }
                                
                                then in my mxml file i have a simple
datagrid
                                
                                <mx:DataGrid 
                                        id="employeeDataGrid" 
                                        width="100%" height="100%" 
                                        dataProvider="{ EmployeesModel.
getInstance( ).employeesList }" 
                                        >
                                with a click listener
                                
                                employeeDataGrid. addEventListener (
MouseEvent.CLICK, clickHandler );
                                
                                and here is clickHandler
                                
                                public function clickHandler(
event:MouseEvent ):void
                                        {
                                            var testVO:EmployeeVO =
EmployeeVO(event. currentTarget. selectedItem) ;
                                            Alert.show(testVO.
employeeID. toString( ));
                                        }
                                
                                and the selectedItem has these
properties.. .
                                
                                employeeID = 1830 [0x726]
                                employeeStatusID = 2
                                employeeTypeID = 1
                                mx_internal_ uid = "D3C...."
                                roleID = 3
                                
                                
                                

                                On Mon, Jun 9, 2008 at 2:39 PM, Sherif
Abdou <[EMAIL PROTECTED] com <mailto:[EMAIL PROTECTED]> > wrote:

                                can you give me a bit of code and I'll
look at it so i can compile the examples 

                                ----- Original Message ----
                                From: Derrick Anderson <no.way.this.
is.in.use@ gmail.com <mailto:[EMAIL PROTECTED]> >

                                To: [EMAIL PROTECTED] ups.com
<mailto:[email protected]> 
                                Sent: Monday, June 9, 2008 1:21:51 PM
                                Subject: Re: [flexcoders] new to VO's,
why won't this cast?

                                i tried your first suggestion, the
second one I had already tried- at least with this one I get an error
                                
                                TypeError: Error #1034: Type Coercion
failed: cannot convert [EMAIL PROTECTED] to com.winn.vo. EmployeeVO.
                                
                                Still the same question though, the
datatypes seem to be compatible- so why the error?
                                
                                thanks,
                                d.

                                On Mon, Jun 9, 2008 at 2:07 PM, Jon
Bradley <[EMAIL PROTECTED] l.com <mailto:[EMAIL PROTECTED]> >
wrote:

                                 

                                On Jun 9, 2008, at 1:54 PM, Derrick
Anderson wrote:

                                
                                
                                

                                var testVO:EmployeeVO = DataGrid(event.
currentTarget) .selectedItem as EmployeeVO;

                                 

                                Maybe this will help:

                                 

                                var testVO:EmployeeVO =
EmployeeVO(event. currentTarget. selectedItem) ;

                                or

                                var testVO:EmployeeVO =
event.currentTarget .selectedItem as EmployeeVO;

                                 

                                good luck,

                                 

                                jon

                                 

                                 

                                 

                                 

                         

                 

                 

         

         

         

        

         

Reply via email to