Hi there,
 
I'm having a little trouble casting results from an RPC to a ValueObject. For example, I'm returning an array of objects from CF the object has two properties and I have created a VO class accordingly:
 
package com.xxx.xxx.model {
 
    [Bindable]
    public dynamic class ModuleVO {
 
        public var module_id:Number;
        public var module_name:String;
 
    }
 
}
 
When the result is returned I cast it as an array and insert it into an ArrayCollection for use in a datagrid (which works fine). I have two text inputs that I want to be binded to the selectedItem in the datagrid. This is where my problems occur:
 
<mx:DataGrid id="dgModules" dataProvider="{ModelLocator.getInstance().modules}"/>
<view:ModuleEditor module="{dgModules.selectedItem as ModuleVO}"/>
 
When the app runs it doesn't cast correctly as a ModuleVO and returns null values. I have checked the properties of the selectedItem in the DataGrid and it has both module_id and module_name but something goes awry in the casting process. I tried adding a constructor to the ModuleVO class that accepts an object:
 
package com.xxx.xxx.model {
 
    [Bindable]
    public dynamic class ModuleVO {
 
        public var module_id:Number;
        public var module_name:String;
 
        public function ModuleVO(module:Object) {
            this.module_id = module.module_id
            this.module_name = module.module_name
        }
 
    }
 
}
 
and changing the Module Editor code to:
 
<mx:DataGrid id="dgModules" dataProvider="{ModelLocator.getInstance().modules}"/>
<view:ModuleEditor module="{new ModuleVO(dgModules.selectedItem)}"/>
 
and it works fine. This method seems like it requires unneccessary lines of code and makes adding further properties a pain in the neck. Can anyone shed any light on where I am going wrong?
 
Thanks in advance,
 
Pete
 

Pete Capra
Information Systems Coordinator
Capra Ryan Online Learning

p. (617) 3208 9455
m. 0411 043 305
f. (617) 3208 9855
a. PO Box 1744 Springwood Q 4127

www.capraryan.com
[EMAIL PROTECTED]

 
__._,_.___

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





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to