Jeff, thanks for that reply. That was perfect. 

One question then... what if a client is closed without releasing the
managed objects? Does the managed state get released if the connection
is severed (like the user closing the window)? Are there any
precautions necessary for cleaning up in this case?

thanks!
Thunder

--- In flexcoders@yahoogroups.com, "Jeff Vroom" <[EMAIL PROTECTED]> wrote:
>
> I think you are talking about "DataService.createItem", not
> "DataService.addItem".   Both approaches will create the item (assuming
> the item you are adding is not already managed on that client).   The
> difference is that createItem adds a separate reference to that managed
> item whereas adding an item to a filled collection.  This difference
> shows up when you start releasing references to managed items.  If you
> call createItem, you need to explicitly release the reference for that
> item using releaseItem.  When you just add the item to a filled array
> collection, when you release that collection using releaseCollection it
> releases the reference for all of the items in the collection.  
> 
>  
> 
> We do reference counting on the client so only when you have released
> the last reference to a managed item is the item's managed state
> released.
> 
>  
> 
> Jeff
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of thunderstumpgesatwork
> Sent: Tuesday, August 01, 2006 12:05 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] DataService addItem vs. adding to a fill()'d
> collection
> 
>  
> 
> Hi all,
> 
> I'm wondering what is the difference between adding an item to a
> managed collection (one gotten from a fill() call) and actually using
> the DataService.addItem() function.
> 
> In the CRM sample, it seems they do it both ways. The code to add a
> company uses DataService.addItem(), and the code to add an employee
> simply adds the employee to the employees collection.
> 
> It appears both have the same affect, in that they are both committed
> to the database immediately, however the approach of adding to the
> managed collection doesn't seem to be working in my environment.
> 
> Just wondering what the differences between these approaches would be.
> 
> thanks,
> Thunder
> 
> P.S. my fill code and add code from my delegate are included below.
> _______________
> 
> public function getDashboards() : void
> {
> call =
> service.fill(
> ConfigModelLocator.getInstance().dashboards,
> "DashboardsByApplicationid",
> [ConfigModelLocator.getInstance().applicationid]);
> 
> service.addEventListener(mx.rpc.events.ResultEvent.RESULT,responder.onRe
> sult);
> service.addEventListener(mx.rpc.events.FaultEvent.FAULT,responder.onFaul
> t);
> }
> 
> public function addDashboard(dashboard:DashboardVO):void
> {
> // validation stuff removed
> // add the dashboard to the dashboards collection
> var dashboardsCol:ArrayCollection =
> ConfigModelLocator.getInstance().dashboards;
> dashboardsCol.addItem(dashboard);
> }
>






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



Reply via email to