init the DS only once in the model, so u always have a reference to it so in GetAllProductsCommand: ds.fill(model.products) in LoadProductCommad: product = Product(myDataGrid.selectedItem); ... now the Ui edits the product object .... so in SaveProductCommand: ds.commit(); Dimitrios Gianninas RIA Developer Optimal Payments Inc.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, February 23, 2007 1:43 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] FDS and Cairngorm / Individual Item Updates Hey All, I'm having an issue finding a best-practice approach for CRUD operations with FDS. Create/Read/Delete are easy, I'm having a problem with updates. I can easily encapsulate CRD's in my Commands, but there doesn't seem to be an option to explicitly commit only a single record with FDS. In a non-cairngorm application, this is pretty easy, I can create a record, then call ds.createItem(), update it and then ds.commit(). The DataService object is local to the interface that is managing the record. No problem, one record committed (correct?). However, with Cairngorm: 1. Get a list of records a. dispatch ProductEvent.GET_ALL b. GetAllProductsCommand.execute() c. ds = new DataService("productHome"); d. ds.fill(model.products); 2. Edit a product a. myList.dataProvider = model.products b. dispatch ProductEvent.EDIT, event.product = myList.selectedItem c. interface changes to the product form d. make modifications via a form e. dispatch ProductEvent.SAVE, event.product = myform.product f. SaveProductCommand.execute() g. ds = new DataService("productHome"); h. ...... how do we commit just this one record? Even if I still had a reference to the original DataService from the fill operation, I may not want to commit all records that changed, only the one that I'm interested in. This would be equivalent to keeping my DataService in my ServiceLocator. The only other option I can think of is that SaveProductCommand works like this, which messes up conflict checks: 1. product = (event as ProductEvent).product; 2. ds = new DataService("productHome"); 3. ds.getItem({product_id: product.product_id}); 4. locally synchronize the item retrieved from ds.getItem() with the product we received in the product event 5. ds.commit() When we do this though, we very likely have the most recent copy of the object from the database, so we're not sure that something hadn't changed before getting it. Am I making this too complex? Is there another way to simply commit one particular record? I can think of all sorts of workarounds, but all of them violate the Cairngorm protocols. I can definitely see the other developers on the team bypassing our Command logic making Cairngorm a little useless :-) Jay Proulx Application Developer Internet Delivery Services - eVision Team [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> (613) 783-6711 -- WARNING ------- This electronic message and its attachments may contain confidential, proprietary or legally privileged information, which is solely for the use of the intended recipient. No privilege or other rights are waived by any unintended transmission or unauthorized retransmission of this message. If you are not the intended recipient of this message, or if you have received it in error, you should immediately stop reading this message and delete it and all attachments from your system. The reading, distribution, copying or other use of this message or its attachments by unintended recipients is unauthorized and may be unlawful. If you have received this e-mail in error, please notify the sender. AVIS IMPORTANT -------------- Ce message électronique et ses pièces jointes peuvent contenir des renseignements confidentiels, exclusifs ou légalement privilégiés destinés au seul usage du destinataire visé. L'expéditeur original ne renonce à aucun privilège ou à aucun autre droit si le présent message a été transmis involontairement ou s'il est retransmis sans son autorisation. Si vous n'êtes pas le destinataire visé du présent message ou si vous l'avez reçu par erreur, veuillez cesser immédiatement de le lire et le supprimer, ainsi que toutes ses pièces jointes, de votre système. La lecture, la distribution, la copie ou tout autre usage du présent message ou de ses pièces jointes par des personnes autres que le destinataire visé ne sont pas autorisés et pourraient être illégaux. Si vous avez reçu ce courrier électronique par erreur, veuillez en aviser l'expéditeur.