Check the code for adding a person to a Brief further down in my previous 
email. If you do it in the EO class, you shouldn't have the problem.

Sent from my iPad

On 2012-04-06, at 4:31 AM, Theodore Petrosky <[email protected]> wrote:

> David,
> 
> I tried this method and still the same issue.
> 
> There is a relationship with a person (user). Without a user added, I get the 
> normal error that I need a user:
> 
> Could not save your changes: A Brief must have a Person.
> 
> I added:
> 
> Person thePerson = session().user().localInstanceIn( ((D2WPage) 
> nextPage).object().editingContext());
> ((D2WComponent) nextPage).object().takeValueForKey( thePerson, "person");
> 
> Thats when I get the infamous:
> 
> Error:     java.lang.IllegalStateException: Adaptor 
> com.webobjects.jdbcadaptor.JDBCAdaptor@3cb088f8 failed to provide new primary 
> keys for entity 'Brief'
> Reason:     Adaptor com.webobjects.jdbcadaptor.JDBCAdaptor@3cb088f8 failed to 
> provide new primary keys for entity 'Brief'
> 
> If it didn't like the person entity or the editingContext, I assume I would 
> get an error complaining about that. 
> 
> This is D2W land and with all the magic going on, I think I am out of Fairy 
> dust.
> 
> Ted
> 
> 
> 
> 
> --- On Thu, 4/5/12, David Holt <[email protected]> wrote:
> 
> | I use this method:
> | 
> | | public WOComponent createPersonAction() {
> | |    return newObjectForEntityName(PERSON);
> | |  }
> | 
> | |  public WOComponent newObjectForEntityName(String entityName) {
> | |    WOComponent nextPage = null;
> | |    try {
> | |      EditPageInterface epi = 
> D2W.factory().editPageForNewObjectWithEntityNamed(entityName, session());
> | |      epi.setNextPage(session().context().page());
> | |      nextPage = (WOComponent) epi;
> | |    }
> | |    catch (IllegalArgumentException e) {
> | |      ErrorPageInterface epf = D2W.factory().errorPage(session());
> | |      epf.setMessage(e.toString());
> | |      epf.setNextPage(session().context().page());
> | |      nextPage = (WOComponent) epf;
> | |    }
> | |    return nextPage;
> | |  }
> | 
> | 
> | On 2012-04-05, at 10:53 AM, Theodore Petrosky wrote:
> | 
> | I am creating a new 'Brief' object in my D2W app like this:
> | 
> | public EditPageInterface createBriefAction() {
> | 
> |     EditPageInterface component = 
> D2W.factory().editPageForNewObjectWithConfigurationNamed("CreateBrief", 
> session());
> |     component.setNextPage(session().context().page());
> | 
> |     if(component instanceof D2WPage) {
> |         D2WPage page = (D2WPage)component;
> |         page.d2wContext().takeValueForKey("Brief.CreateBrief", 
> "navigationState");
> | 
> | This could be a rule:
> | 50 : pageConfiguration = 'CreateBrief' => navigationState = 
> "Brief.CreateBrief" [com.webobjects.directtoweb.Assignment]
> | 
> |         NSLog.out.appendln( ((D2WPage) 
> component).object().allPropertyKeys());
> |             
> |         Person thePerson = session().user().localInstanceIn(((D2WPage) 
> component).object().editingContext());
> | 
> |         ((D2WComponent) component).object().takeValueForKey( thePerson, 
> "person");
> |         ((D2WComponent) component).object().takeValueForKey( (new 
> NSTimestamp()), "creationDate");//  (new NSTimestamp());
> | 
> | This code should be in your Brief eo init() method. Something like:
> | 
> | |  public void init(EOEditingContext ec) {
> | |    super.init(ec);
> | |    Person thePerson = session().user().localInstanceIn(ec);
> | |    setPersonRelationship(thePerson);
> | |    setCreationDate(new NSTimestamp());
> | |  }
> | 
> |             
> | |    }
> | |  return component;
> | }
> | 
> | When I click the save button I am getting:
> | 
> | 
> | IllegalStateException: Adaptor 
> com.webobjects.jdbcadaptor.JDBCAdaptor@43c8308 failed to provide new primary 
> keys for entity 'Brief'
> | 
> | 
> | Am I supposed to do something more here?
> | 
> | Ted public WOComponent createPersonAction() {
> | |    return newObjectForEntityName(PERSON);
> | |  }
> | 
> | |  public WOComponent newObjectForEntityName(String entityName) {
> | |    WOComponent nextPage = null;
> | |    try {
> | |      EditPageInterface epi = 
> D2W.factory().editPageForNewObjectWithEntityNamed(entityName, session());
> | |      epi.setNextPage(session().context().page());
> | |      nextPage = (WOComponent) epi;
> | |    }
> | |    catch (IllegalArgumentException e) {
> | |      ErrorPageInterface epf = D2W.factory().errorPage(session());
> | |      epf.setMessage(e.toString());
> | |      epf.setNextPage(session().context().page());
> | |      nextPage = (WOComponent) epf;
> | |    }
> | |    return nextPage;
> | |  }
> | 
> | 
> | On 2012-04-05, at 10:53 AM, Theodore Petrosky wrote:
> | 
> | I am creating a new 'Brief' object in my D2W app like this:
> | 
> | public EditPageInterface createBriefAction() {
> | 
> |     EditPageInterface component = 
> D2W.factory().editPageForNewObjectWithConfigurationNamed("CreateBrief", 
> session());
> |     component.setNextPage(session().context().page());
> | 
> |     if(component instanceof D2WPage) {
> |         D2WPage page = (D2WPage)component;
> |         page.d2wContext().takeValueForKey("Brief.CreateBrief", 
> "navigationState");
> | 
> | This could be a rule:
> | 50 : pageConfiguration = 'CreateBrief' => navigationState = 
> "Brief.CreateBrief" [com.webobjects.directtoweb.Assignment]
> | 
> |         NSLog.out.appendln( ((D2WPage) 
> component).object().allPropertyKeys());
> |             
> |         Person thePerson = session().user().localInstanceIn(((D2WPage) 
> component).object().editingContext());
> | 
> |         ((D2WComponent) component).object().takeValueForKey( thePerson, 
> "person");
> |         ((D2WComponent) component).object().takeValueForKey( (new 
> NSTimestamp()), "creationDate");//  (new NSTimestamp());
> | 
> | This code should be in your Brief eo init() method. Something like:
> | 
> | |  public void init(EOEditingContext ec) {
> | |    super.init(ec);
> | |    Person thePerson = session().user().localInstanceIn(ec);
> | |    setPersonRelationship(thePerson);
> | |    setCreationDate(new NSTimestamp());
> | |  }
> | 
> |             
> | |    }
> | |  return component;
> | }
> | 
> | When I click the save button I am getting:
> | 
> | 
> | IllegalStateException: Adaptor 
> com.webobjects.jdbcadaptor.JDBCAdaptor@43c8308 failed to provide new primary 
> keys for entity 'Brief'
> | 
> | 
> | Am I supposed to do something more here?
> | 
> | Ted
> 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to