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
> _______________________________________________
> 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/programmingosx%40mac.com
> 
> This email sent to [email protected]

 _______________________________________________
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