Creating related objects and multiple ECs
Creating related objects and multiple ECs
- Subject: Creating related objects and multiple ECs
- From: David LeBer <email@hidden>
- Date: Tue, 16 Feb 2010 16:32:15 -0500
This is something I've run into multiple times, hacked something to work, and then thought there must be a better way.
The scenario:
------------------
I have Studio <studio*----------movies>> Movie
If I create a new Studio, I will use a generic Studio edit form to set it's values, the form has a button that allows the user to add a new related Movie.
Here's the conundrum:
------------------------------
- If I use the same EC for the Movie, and the user cancels in the Movie's Edit form, the EC will get reverted (bad).
- If I use a nested EC for the Movie, I cannot build a relationship between it and the Studio (because they are in different ecs), I cannot call local instance on the Studio because it hasn't been committed yet, and I cannot call local instance on the Movie until after it's ec has been saved, which will unfortunately throw a validation error (because it's Studio relationship is required in the model).
Things I've done in the past:
-------------------------------------
- Disable adding Movies to a Studio until the Studio has been committed (then local instance will work).
- Modify the model so that the to-one relationship from Movie -> Studio is not mandatory, and hide the to-one edit widget in the Movie form for newly minted Movies, and then set the relationship between the two AFTER the Movie has been successfully saved and we are heading back to the Studio form.
When rolling my own edit forms, this not so much of an issue, but in D2W where everything is generic it bites, I hate having to write custom rules and modify the model to work around this.
Anyone have an magical solution that I am missing?
;david
--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
twitter: http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden