You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by m-woelm <ma...@m-woelm.de> on 2006/09/10 16:13:07 UTC
Question: Can not get access to object fields (Null Pointer Exception)
Hi,
I hope anybody could explain me why I get a Null Pointer Exception, if I
want to get access to field of an object. My method is similar to the
eshop-project of the book Enjoying web dev with Tapestry.
I tried to change the Listener-method onLogin as follows:
public void onLogin(IRequestCycle cycle) {
try {
User user = Users.getKnownUsers().getUser(email,password);
getUser().copyFrom(user);
if (user.getState().equals("admin"))
cycle.activate("Admin_Konsole");
else cycle.activate("User_Konsole");
} catch (AuthenticationException e) {
ValidationDelegate delegate = getDelegate();
delegate.setFormComponent(null);
delegate.record("Login failed", null);
}
}
Now I get an exception at point (user.getState().equals(admin)).
But why? user was set to the login-user two lines before? Why I cant get
the field: private String state which I have set in User.class:
private String state;
public String getState() {
return this.state;
}
Thx ahead!
Michael Wölm
<ma...@m-woelm.de> mail@m-woelm.de
Public Key: <http://gsg.ath.cx/~phoenix/downloads/MyPublicKey.asc>
href="http://gsg.ath.cx/~phoenix/downloads/MyPublicKey.asc