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.onResult);
service.addEventListener(mx.rpc.events.FaultEvent.FAULT,responder.onFault);
}

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





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