• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: insertObject error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: insertObject error


  • Subject: Re: insertObject error
  • From: wojingo <email@hidden>
  • Date: Fri, 23 Dec 2005 12:30:09 +1030

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 (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >insertObject error (From: vjc <email@hidden>)

  • Prev by Date: insertObject error
  • Next by Date: Customize "application not found" error
  • Previous by thread: insertObject error
  • Next by thread: Avoid piracy of WO app
  • Index(es):
    • Date
    • Thread