vjc wrote:
Heylo,

I am trying to create a form that will add the values to my database. The table's primary key, aid, is an auto increment column. Whenever I fill all of the values in the form and hit submit to add the data to the database, I get the following error:

Application: OnTrack
Error: java.lang.IllegalArgumentException: attempt to insert a null object into this context
Reason: attempt to insert a null object into this context

This is telling you that your EO is null. That is, you havent got an object - just a null reference.


I have checked to make sure that I am not leaving out any fields that are not null. As a matter of fact, the only field I am leaving out is the aid field. Here is my data for the submit button:

public WOComponent addAnnouncement()
    {
        EOEditingContext ec = session().defaultEditingContext();
        ec.insertObject(newAnnouncement);
        ec.saveChanges();
        newAnnouncement = new Announcement();
        return null;
    }

I am confused and tired.  Any help is greatly appreciated.


You need to create the Announcment object before you insert into the editingContext. Your reference newAnnouncment is null, that is you cannot insert a null into the editingContext.
eg)

 public WOComponent addAnnouncement()
     {
         newAnnouncement = new Announcement();
         EOEditingContext ec = session().defaultEditingContext();
         ec.insertObject(newAnnouncement);
         ec.saveChanges();
         return null;
     }


regards,
- shaun
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to