I could, but display (since the CalendarEditor component expects data from a Calendar) is still an issue, no? Perhaps I should just be doing what the DataGrid does when outfitted with an itemEditor and just assume that I should operate on the data directly. I can re-request the unaltered object from the server if the users cancels the edit.
-----Original Message----- From: Tracy Spratt <tspr...@lariatinc.com> Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] design question: editing / saving complex valueobjects Date: Thu, 19 Feb 2009 14:36:42 -0500 Can you make the validation functionality independently available? Tracy Spratt Lariat Services Flex development bandwidth available ________________________________________________________________________ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Maciek Sakrejda Sent: Thursday, February 19, 2009 11:21 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] design question: editing / saving complex valueobjects Anyone? I'm sure this sort of thing comes up pretty frequently--I'd be curious to know how other Flex users tackle it. -Maciek -----Original Message----- From: Maciek Sakrejda <msakre...@truviso.com> Reply-To: flexcoders@yahoogroups.com To: flexcoders <flexcoders@yahoogroups.com> Subject: [flexcoders] design question: editing / saving complex value objects Date: Wed, 18 Feb 2009 10:35:04 -0800 Suppose I have a class Calendar that mirrors a server-side class (we're not really working with Calendars, but I think this is a reasonably good and simple analogy): class Calendar { public var appointments:ArrayCollection; /* other stuff */ } Then I want users to be able to edit and save the Calendar: I have a CalendarEditor. Editing a Calendar is moderately complicated (e.g., adding, removing, or editing Appointments), so I want explicit save/cancel steps. When editing something really simple, this is not really a problem--when the user saves, I propagate the view state to the object; when she hits cancel, I don't do anything. However, the Calendar determines what combination of Appointments is valid (they can't overlap), and the Calendar is the dataProvider of the CalendarEditor, so I can't fully validate a combination of Appointments without adding them to the Calendar. This means I actually need to add the appointments to the Calendar before it is saved so that they can be (a) validated in combination and (b) used to update the view while the edit is in progress. This makes save/cancel steps trickier: do I (1) Clone the Calendar (and therefore have it provide a clone() method) when assigned in the dataProvider, modify the clone, and assign the dataProvider reference when the user hits save. (2) Clone the Calendar as above, but have the Editor modify the original, and restore the clone in case the user cancels. (3) Something more clever? The problem with (1) is that cloning may be somewhat complicated, and it "feels" ugly to have the Editor update the dataProvider reference (instead of modifying the actual object that was set as the data provider). (2) hits the same issue. Perhaps the solution is to maintain a private clone, and copy back the state on save? Or is the right answer here that the model should not expect that the editor will update the object it set as the dataProvider, but should instead expect an update through a mechanism like a Mate map? Any thoughts? (Please keep in mind that my experience with MVC frameworks is unfortunately minimal, though I'm looking into Mate right now). Thanks, Maciek