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 [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




__,_._,___

Reply via email to