• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EditingContext Newbiee Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EditingContext Newbiee Question


  • Subject: Re: EditingContext Newbiee Question
  • From: David LeBer <email@hidden>
  • Date: Fri, 1 Aug 2008 23:22:51 -0400


On 1-Aug-08, at 8:33 PM, Gustavo Pizano wrote:

Hello everyone, I just wanted to ask a noob question. Everywhere I look I see about the EditingConext, as I know, it function its to hold instances of the EO's so they can interact each other and so.
in the tutorials and the documentations, they talk most of the part about the defaultEditingContext, from the session, or the apllication, so my question is, when its necessary to use the defaultEditingContext, and to create a new one?.
This thing about the EditingContext its spining my head a little.

Tutorials generally don't use anything other than the defaultEditingContext because it adds a layer of complexity that the authors (I assume) feel will detract from the core purpose of the tutorial.


However, this tends to give beginners a false impression of how most real-world applications are written and also fails to demonstrate the pitfalls of a single EC design.

Lets take a (completely contrived) example:

Your application is using the defaultEditingContext. Your user enters a form that creates a new EO. Half way through they decide to abort and hit the back button a couple of times and go somewhere else in the site.

The defaultEditingContext is now dirtied with that new EO. If the user later performs any action that calls saveChanges on the defaultEC it will try and commit the EO, it might fail giving your user a completely unexplainable validation error, or it might succeed saving unwanted and probably invalid data.

So my general rule of thumb is to never use the defaultEditingContext for any edit actions. I always create new ECs for any task that is going to require editing.

Using Project Wonder's ERXEC makes this particularly painless as it handles the necessary EC locking automagically.

Other options are documented here: <http://wiki.objectstyle.org/confluence/display/WO/EOF-Using+EOF-Context+and+Database+Locking >

;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
  • Follow-Ups:
    • Re: EditingContext Newbiee Question
      • From: Gustavo Pizano <email@hidden>
    • Re: EditingContext Newbiee Question
      • From: Jeff Schmitz <email@hidden>
References: 
 >EditingContext Newbiee Question (From: Gustavo Pizano <email@hidden>)

  • Prev by Date: EditingContext Newbiee Question
  • Next by Date: WO5.4 Web Services - Application not responding
  • Previous by thread: EditingContext Newbiee Question
  • Next by thread: Re: EditingContext Newbiee Question
  • Index(es):
    • Date
    • Thread