[flexcoders] Re: FDS - how do I manage a single item?
I have finally got it to work. Thank a lot, Jeff. --- In flexcoders@yahoogroups.com, Jeff Vroom [EMAIL PROTECTED] wrote: There are a few examples in the flexcab sample (samples/dataservice/flexcab). Here's a snippet from one of these: var itemRef:ItemReference = ServiceLocator.getInstance().cabService.getItem({name: newCab.name}, newCab); itemRef.addResponder(new ItemResponder( function (resultEvent:ResultEvent, token:Object=null):void { cab = itemRef.result as Cab; // Second rpc call snipped from here }, function (faultEvent:FaultEvent, token:Object=null):void { Alert.show(faultEvent.fault.faultString, Error Logging In); })); Jeff From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dmitry Miller Sent: Tuesday, August 01, 2006 2:20 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: FDS - how do I manage a single item? Jeff, hi I am trying to retrieve item by its id. And I tried your suggestion yesterday. var ir:ItemReference = ds.getItem({id:userId}); Now, given the item reference (ir) how do I connect ir to the actual variable (me)? When I tried me = User(ir.result); Flex started compaining. Could you, please, give a code snippet? Thanks a lot --- Dmitry --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , jeffjvroom jvroom@ wrote: Either with dataService.getItem, if the item exists and you have its id or dataService.createItem if the item does not exist and you want to create a new one. If you need to actually execute a query to retrieve the item (e.g. you are trying to retrieve a User by the lastName), you have to use the fill method to pass in the parameters and just have that fill method return a Collection with just one item. In this case, the fill method returns an AsyncToken whose responder will be called when the fill results are returned to the client. At that point, you could look at the filled array collection and call getItemAt(0) to get the first item in the list. Jeff --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Dmitry Miller goblin77@ wrote: I have a managed class. [Managed] class User { } and in the main application .mxml file I have a reference of this type that I want to manage by a data service i.e. mx:DataService id=ds destination=userSvc / mx:Script [Bindable] public var me:User; /mx:Script Now, how do I get to populate variable me and get it maneged by userSvc? Thanks, --- Dmitry -- 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/ * 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/
[flexcoders] Re: FDS - how do I manage a single item?
Either with dataService.getItem, if the item exists and you have its id or dataService.createItem if the item does not exist and you want to create a new one. If you need to actually execute a query to retrieve the item (e.g. you are trying to retrieve a User by the lastName), you have to use the fill method to pass in the parameters and just have that fill method return a Collection with just one item. In this case, the fill method returns an AsyncToken whose responder will be called when the fill results are returned to the client. At that point, you could look at the filled array collection and call getItemAt(0) to get the first item in the list. Jeff --- In flexcoders@yahoogroups.com, Dmitry Miller [EMAIL PROTECTED] wrote: I have a managed class. [Managed] class User { } and in the main application .mxml file I have a reference of this type that I want to manage by a data service i.e. mx:DataService id=ds destination=userSvc / mx:Script [Bindable] public var me:User; /mx:Script Now, how do I get to populate variable me and get it maneged by userSvc? Thanks, --- Dmitry -- 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/ * 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/
[flexcoders] Re: FDS - how do I manage a single item?
Jeff, hi I am trying to retrieve item by its id. And I tried your suggestion yesterday. var ir:ItemReference = ds.getItem({id:userId}); Now, given the item reference (ir) how do I connect ir to the actual variable (me)? When I tried me = User(ir.result); Flex started compaining. Could you, please, give a code snippet? Thanks a lot --- Dmitry --- In flexcoders@yahoogroups.com, jeffjvroom [EMAIL PROTECTED] wrote: Either with dataService.getItem, if the item exists and you have its id or dataService.createItem if the item does not exist and you want to create a new one. If you need to actually execute a query to retrieve the item (e.g. you are trying to retrieve a User by the lastName), you have to use the fill method to pass in the parameters and just have that fill method return a Collection with just one item. In this case, the fill method returns an AsyncToken whose responder will be called when the fill results are returned to the client. At that point, you could look at the filled array collection and call getItemAt(0) to get the first item in the list. Jeff --- In flexcoders@yahoogroups.com, Dmitry Miller goblin77@ wrote: I have a managed class. [Managed] class User { } and in the main application .mxml file I have a reference of this type that I want to manage by a data service i.e. mx:DataService id=ds destination=userSvc / mx:Script [Bindable] public var me:User; /mx:Script Now, how do I get to populate variable me and get it maneged by userSvc? Thanks, --- Dmitry -- 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/ * 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/
RE: [flexcoders] Re: FDS - how do I manage a single item?
There are a few examples in the flexcab sample (samples/dataservice/flexcab). Heres a snippet from one of these: var itemRef:ItemReference = ServiceLocator.getInstance().cabService.getItem({name: newCab.name}, newCab); itemRef.addResponder(new ItemResponder( function (resultEvent:ResultEvent, token:Object=null):void { cab = itemRef.result as Cab; // . Second rpc call snipped from here }, function (faultEvent:FaultEvent, token:Object=null):void { Alert.show(faultEvent.fault.faultString, Error Logging In); })); Jeff From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dmitry Miller Sent: Tuesday, August 01, 2006 2:20 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: FDS - how do I manage a single item? Jeff, hi I am trying to retrieve item by its id. And I tried your suggestion yesterday. var ir:ItemReference = ds.getItem({id:userId}); Now, given the item reference (ir) how do I connect ir to the actual variable (me)? When I tried me = User(ir.result); Flex started compaining. Could you, please, give a code snippet? Thanks a lot --- Dmitry --- In [EMAIL PROTECTED]ups.com, jeffjvroom [EMAIL PROTECTED] wrote: Either with dataService.getItem, if the item exists and you have its id or dataService.createItem if the item does not exist and you want to create a new one. If you need to actually execute a query to retrieve the item (e.g. you are trying to retrieve a User by the lastName), you have to use the fill method to pass in the parameters and just have that fill method return a Collection with just one item. In this case, the fill method returns an AsyncToken whose responder will be called when the fill results are returned to the client. At that point, you could look at the filled array collection and call getItemAt(0) to get the first item in the list. Jeff --- In [EMAIL PROTECTED]ups.com, Dmitry Miller goblin77@ wrote: I have a managed class. [Managed] class User { } and in the main application .mxml file I have a reference of this type that I want to manage by a data service i.e. mx:DataService id=ds destination=userSvc / mx:Script [Bindable] public var me:User; /mx:Script Now, how do I get to populate variable me and get it maneged by userSvc? Thanks, --- Dmitry __._,_.___ -- 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 Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. __,_._,___