Re: Another simple problem I am clueless about...
Re: Another simple problem I am clueless about...
- Subject: Re: Another simple problem I am clueless about...
- From: Ray Kiddy <email@hidden>
- Date: Fri, 16 Mar 2007 16:30:10 -0700
On Mar 16, 2007, at 2:23 PM, Kevin Windham wrote:
I have a User object with an email() method. This is the standard
boilerplate generated by EOModeler from my User table.
public String email() {
return (String)storedValueForKey("email");
}
I have a registration page with a field on the page bound to
user.email and a method called fieldsValidate(). When I get to the
line ckEmail = user.email(); I get a null pointer exception.
user.email() is returning null. I am not sure why? The
registerNewUser method works fine if I take out the fieldsValidate
(). Can someone hit me with the clue-by-4.
Which is it? You are saying that when you "get to the line ckEmail =
user.email()", you get an NPE, and you are saying that "user.email()
is returning null".
If the user.email() call is giving an NPE, then user is null. If
user.email() is returning null, then user is not null. Then, the line
that had "ckEmail.someMethod()" would be getting the NPE.
So, which is it?
- ray
Thanks,
Kevin
public class MyAccount_ActivateNewAccount extends WOComponent {
public User user;
public String confirmPassword;
public Boolean error;
protected String
ckEmail,ckFirstName,ckLastName,ckaddress1,ckCity,ckState,ckZip;
public MyAccount_ActivateNewAccount(WOContext context) {
super(context);
user = new User();
}
public Boolean fieldsValidate()
{
String highlight = "background: yellow;";
ckEmail = user.email();
if (ckEmail.equals("")) {
ckEmail = highlight;
} else { ckEmail = ""; }
if ((ckEmail+ckFirstName+ckLastName+ckaddress1+ckCity+ckState
+ckZip).equals("")) {
return true;
}
else {
return false;
}
}
public WOComponent registerNewUser()
{
if (fieldsValidate()) {
EOEditingContext ec = session().defaultEditingContext();
NSMutableArray arguments = new NSMutableArray();
arguments.addObject(user.email());
EOQualifier qualifier = EOQualifier.qualifierWithQualifierFormat
("email = %@", arguments);
EOFetchSpecification fetchSpec = new EOFetchSpecification
("User",qualifier,null);
NSArray results = new NSArray(ec.objectsWithFetchSpecification
(fetchSpec));
if (results.count() == 0) {
ec.insertObject(user);
ec.saveChanges();
}
else {
return null;
}
MyAccount_RegistrationConfirmation nextPage =
(MyAccount_RegistrationConfirmation)pageWithName
("MyAccount_RegistrationConfirmation");
// Initialize your component here
nextPage.userID = user.email();
nextPage.password = user.password();
return nextPage;
}
else {
return null;
}
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40ganymede.org
This email sent to email@hidden
_______________________________________________
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