Re: can not save to defaultEditingContext
Re: can not save to defaultEditingContext
- Subject: Re: can not save to defaultEditingContext
- From: "Jonathan Fleming" <email@hidden>
- Date: Fri, 07 Feb 2003 18:25:47 +0000
This is the method that returns the tbClient to be added to the tbAdminUser
relationship
public WOComponent addClientToAdminUser() {
if (tb_AdminUserID.equals("testMethod")) {
CreditCardPayment nextPage =
(CreditCardPayment)pageWithName("CreditCardPayment");
return nextPage;
}
else {
// get editing context
EOEditingContext ec = session().defaultEditingContext();
// create new tbClient object
TbClient newTbClient = new TbClient();
newTbClient.setLastName("Required");
newTbClient.setArtisteName("Not_Required_If_Artiste_Is_Filled_In");
newTbClient.setCompanyName("Not_Required_If_Artiste_Is_Filled_In");
newTbClient.setAddressLine1("Required");
newTbClient.setCityTown("Required");
newTbClient.setPostCode("Required");
newTbClient.setEmail1("Required");
newTbClient.setMetaDescription("Required");
// create new tbClientData object
TbClientData newTbClientData = new TbClientData();
// insert new tbClient into editing context
ec.insertObject(newTbClient);
// insert new tbClientData into editing context
ec.insertObject(newTbClientData);
// add new tbClient to tbClients relationship and set the
tbAdminUser for it
tbAdminUser.addObjectToBothSidesOfRelationshipWithKey(newTbClient,
"tbClients");
// add new tbClientData to tbClient relationship and set the
tbClient for it
tbClient.addObjectToBothSidesOfRelationshipWithKey(newTbClientData,
"tbClientData");
setReadyNewClient("Enter The New Client's Details");
// set the tbClient to newTbClient so the item can be entered in
the list
tbClientData = newTbClientData;
tbClient = newTbClient;
NSLog.out.appendln("This is what's in the
defaultEditingContext() " + ec);
return null;
}
}
From: Michael Kondratov <email@hidden>
To: "Jonathan Fleming" <email@hidden>
Subject: Re: can not save to defaultEditingContext
Date: Fri, 7 Feb 2003 12:44:43 -0500
Ok..
A sample code
SomeObject someObject = new SomeObject(); // Creating a new EO objects
this.session().defaultEditingContext().insertObject(someObject); //
Insert EOinto editing context
someObject.takeValueForKey(value,"key"); // make modifications to new
objects
this.session().defaultEditingContext().saveChnages(); // save object
Michael
www.aspireauctions.com
On Friday, February 7, 2003, at 12:08 PM, Jonathan Fleming wrote:
Before the problem, here's the relationship of the entity's: tbAdminUser
has a toMany relationship with >> < tbClient which has a toOne
relationship with tbAdminUser. tbClient goes on to have a oneToOne
relationship with tbClientData and oneToOne back
After logging in as the registered user I make an attempt to create a
new tbClient (account/object/row) and the form loads with the required
setting, but when I submit to save I get this Error
Error: java.lang.IllegalStateException
Reason: Cannot obtain globalId for an object which is not registered in
any editingContext, object: {values = {modificationDate =
<com.webobjects.foundation.NSKeyValueCoding$Null>; clientRefNo =
<com.webobjects.foundation.NSKeyValueCoding$Null>; tbClientData =
"<TbClientData 61dfb5 <EOTemporaryGlobalID: 0 0 -64 -88 0 5 0 0 11 -77 3
0 0 0 0 -13 56 113 104 -1 -10 -55 -6 78>>"; regRenewalReminderDate =
<com.webobjects.foundation.NSKeyValueCoding$Null>; companyName =
<com.webobjects.foundation.NSKeyValueCoding$Null>; addressLine1 =
<com.webobjects.foundation.NSKeyValueCoding$Null>; addressLine2 =
<com.webobjects.foundation.NSKeyValueCoding$Null>; tbCatJoin_tbCategorys
= "null"; artisteName =
<com.webobjects.foundation.NSKeyValueCoding$Null>; lastName =
<com.webobjects.foundation.NSKeyValueCoding$Null>; }; this = "<TbClient
36a43c [Gid Not Found]>"; }, databaseContext:
com.webobjects.eoaccess.EODatabaseContext@439a20, object's
editingContext: null, databaseContext's active editingContext:
com.webobjects.eocontrol.EOEditingContext@1e29fb
_________________________________________________________________
Chat online in real time with MSN Messenger http://messenger.msn.co.uk
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_________________________________________________________________
Stay in touch with MSN Messenger http://messenger.msn.co.uk
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.