• 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: Another simple problem I am clueless about...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another simple problem I am clueless about...


  • Subject: Re: Another simple problem I am clueless about...
  • From: Kevin Windham <email@hidden>
  • Date: Fri, 16 Mar 2007 18:35:56 -0500


On Mar 16, 2007, at 6:30 PM, Ray Kiddy wrote:


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

Sorry, I explained that poorly. I was getting an NPE, so I moved the user.email().equals("") part of my if into two lines. The NPE now occurs on the if line. By separating the line out I discovered that user.email() is returning null and my if becomes if (null) which throws the NPE.





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: This email sent to email@hidden
References: 
 >Another simple problem I am clueless about... (From: Kevin Windham <email@hidden>)
 >Re: Another simple problem I am clueless about... (From: Ray Kiddy <email@hidden>)

  • Prev by Date: Re: Another simple problem I am clueless about...
  • Next by Date: Re: Another simple problem I am clueless about...
  • Previous by thread: Re: Another simple problem I am clueless about...
  • Next by thread: Re: Another simple problem I am clueless about...
  • Index(es):
    • Date
    • Thread