[flexcoders] Re: LCDS - adding a new Item using createItem()

2009-01-19 Thread benjidudu
I had the same problem and I ended with the following solution:
Add an event listener on your collection like this:
groups.addEventListener(CollectionEvent.COLLECTION_CHANGE, 
onDataChanged);
In the onDataChanged function, look if the 'kind' property of the 
event is CollectionEventKind.UPDATE.
Then you can find the id with something like that:
if (ev.items.length  0)
{
var pce:PropertyChangeEvent = ev.items[0] as 
PropertyChangeEvent;
var id:Number = pce.currentTarget.id;
}

Hope it helps,
Benjamin.

--- In flexcoders@yahoogroups.com, Besite - Bart b...@... wrote:

 Hello,
 
 In my Data Management Service I create a new User-object using the 
 createItem() function :
 
  ds.createItem(new User(Jeff));
 var token:AsyncToken = ds.commit();
  token.kind = create;
 
 When the commit is sent, the new User is persisted to the server... 
In 
 my database an autoincrement id is generated,
 but the object returned to the Flex client has still an id equal to 
0.
 
 How do I know the unique id of the created User-object on the 
 client-side ? I need this unique id to do some remote calls as soon 
as 
 it is created on the server...
 
 Any help is welcome !
 
 Kind regards
 Bart






Re: [flexcoders] Re: LCDS - adding a new Item using createItem()

2009-01-19 Thread João Fernandes
Bart, during the sync method, when you create your bean, are you setting 
the new generated Id back again into the bean?

-- 

João Fernandes

Adobe Certified Expert
Adobe Community Expert
http://www.onflexwithcf.org
http://www.riapt.org
Portugal Adobe User Group (http://aug.riapt.org)