On 20/01/2010, at 5:16 AM, Chuck Hill wrote: >> I was just reading Johan Henselmans's thread entitled "validating deleting >> an object with relationship", and it reminded me of a similar question I had >> recently: is there a convenient way to ask EOF if a particular EO _would be_ >> deletable if I tried to delete it? > > No. The stock validateForDelete() does not follow the the relationships and > call validateForDelete() on the to-many with a Cascade delete rule. This > does not happen until saveChanges(). > >> I have a component where I list some EOs, and I want to offer a "Delete" >> hyperlink next to only those which would be deletable given the model's >> delete rules. Is the easiest way to do this to call validateForDelete() and >> see if it throws a ValidationException? I assume that would answer the >> question, it just seems a bit clumsy. > > That will answer it for that one object directly, but the delete may be > thwarted by a related object's validateForDelete().
Ah, OK. > I'd add a custom method like public boolean canBeDeleted() and then also use > that in validateForDelete(). Right. Will do. -- Paul. http://logicsquad.net/ _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
