If I've made a class for an EO entity, can I use it to add data to?
If I've made a class for an EO entity, can I use it to add data to?
- Subject: If I've made a class for an EO entity, can I use it to add data to?
- From: Amorya North <email@hidden>
- Date: Tue, 20 Jul 2004 13:57:24 +0100
I'm implementing a registration page for users on my site.
I have an EO Entity called Members. This maps onto a Java class called
Members (class generated by EOModeller).
What I want to do is add data directly to a new Members object...
I created a key in WOBuilder called creatingMember, of type Members. I
then assigned fields in my registration form to values for this new
member.
Then, I added this code to the action:
if (creatingMember.password().equals( password )) {
} else {
return null;
}
//
// Check to see if a user with this username already exists
//
EOQualifier qual;
EOFetchSpecification fs;
NSMutableArray args = new NSMutableArray();
EOEditingContext ec = new EOEditingContext();
args.addObject(creatingMember.username());
qual = EOQualifier.qualifierWithQualifierFormat
("username = %@", args);
fs=new EOFetchSpecification("Members", qual, null);
NSArray im=ec.objectsWithFetchSpecification(fs);
if(im.count()==1) {
ec.insertObject(creatingMember);
creatingMember = null;
ec.saveChanges();
} else {
return null;
}
I get a null pointer exception when I try and run it. The null pointer
is at this line:
if (creatingMember.password().equals( password )) {
I suddenly had a thought that perhaps it wouldn't like a Members object
that wasn't yet in the database. I know I could do all this by
assigning a key to every field in my form (username, email, etc) and
then adding them via code, but I want to avoid doing that... soon I'll
be writing a huge multi-page submission form, and adding the data
directly from the form to an EO would be much much easier than
otherwise - so I'd like to use this one to practice!
Any idea why it's borked?
Amorya
_______________________________________________
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.