X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.22.2a (ClamAV engine v0.102.2) X-Junk-Score: 0 [] X-KAS-Score: 0 [] From: "Samuel Pelletier" Received: from fortimail.cybercat.ca ([216.13.210.77] verified) by post.selbstdenker.com (CommuniGate Pro SMTP 6.3.3) with ESMTPS id 26614922 for webobjects-dev@wocommunity.org; Sun, 17 Oct 2021 17:47:43 +0200 Received-SPF: none receiver=post.selbstdenker.com; client-ip=216.13.210.77; envelope-from=samuel@samkar.com Received: from smtpclient.apple (modemcable213.203-171.107.mc.videotron.ca [107.171.203.213]) (user=samuel%samkar.com mech=PLAIN bits=0) by fortimail.cybercat.ca with ESMTP id 19HFlKXV013136-19HFlKXW013136 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 17 Oct 2021 11:47:21 -0400 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [WO-DEV] localinstance for not-yet-saved EOs? Date: Sun, 17 Oct 2021 11:47:20 -0400 References: To: WebObjects & WOnder Development In-Reply-To: Message-Id: <3F1B4B57-204E-470F-9C79-6162CAE2F39C@samkar.com> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-FEAS-AUTH-USER: samuel%samkar.com Hi Markus, Passing an EO to another EditingContext requires that this EO exists in = the parent object store of the new ec knows about this EOGlobalID to = retrieve the data snapshot. If an object is committed to the database, the root ObjectStore can = retrieve it's data from the DB so it always works. In your case, I see 2 solutions, both require that the ec used in the = picking phase know about the main ec use to edit the main object. If you = pass the main object (even if not saved yet, you can get it's ec. 1- You use the main edited object's EOEditingContext in the picker but = you loose the isolation if the changes... 2- You use the main edited object ec as the parent object store of the = picking EOEditingContext like this: EOEditingContext ec =3D ERXEC.newEditingContext(); // Main ec EOEditingContext subEc =3D ERXEC.newEditingContext(ec); // In = the picking sub component With solution 2, saving into subEc will commit the changes to the main = ec (nothing sent to the database yet). You can then localInstance = objects from the sebEc into the main ec. You can cascade this as deep or wide as required. Hope this can help you, Samuel > Le 15 oct. 2021 =C3=A0 08:48, Markus Ruggiero (rucotec) = a =C3=A9crit : >=20 > LocalInstance is only allowed for EOs that have already been saved. If = isNewObject() return true then any form of localinstance call returns an = exception. Why? And how can I overcome this? >=20 > I have the following scenario:=20 >=20 > The user picks existing EOs to be worked on at a later point in time. = They can also create on-the-fly new EOs for picking. All EOs as well as = the new ones are associated with the current editing context. The whole = list of picked objects (NSArray containing existing and new EOs) is then = passed to the next page and on to the next. In each step some of the EOs = are modified in various ways until about 3 steps down the line a final = saveChanges() is done. All fine so far.=20 >=20 > But on each step the user can go back up one step (either browser back = button or with a dedicated navigation button on the page). The page = cache takes care of this but the EOs themselves are not in the page = cache and remain modified in their EC. Coming back the previous / first = page does not show the initial state anymore. Ok, easy to solve = (methinks): map the EOs into a new editing context right before going to = the next step. Coming back then automatically throws away that EC. Going = forward again will create a brand new EC. But! localInstancing into the = new EC only works for saved EOs. How do I get these new EOs into the = nextPhaseEC? The new EOs are fairly complex and already have = relationships to other EOs. How can I re-wire the new EOs? >=20 > Thanks for any help > ---markus--- >=20