sorry: s/undefined/uninitialised
On Fri, 2011-04-08 at 13:47 +0100, Richard Hill wrote: > Well you can't call a method on null! null is not a String with value > "null". It's a special value in java - basically a reference to a value > called null (i.e distinct from an undefined variable that has no > reference assigned). You need to check for a null value before calling > any methods: > > if(user.getUserType() != null && > user.getUserType().equalsIgnoreCase("Admin")) { > > .... > > > > > On Fri, 2011-04-08 at 05:38 -0700, robnangle wrote: > > Richard Hill-7 wrote: > > > > > > You don't say what line your getting your npe but I'm guessing it's > > > this: > > > > > > if(user.getUserType().equalsIgnoreCase("Admin") > > > > > > if .getUserType() is null as you imply it can be then > > > calling .equalsIgnorecase() is going to result in an npe. > > > > > > > Ye thats the line im getting it on. Yes everybodys userType will be null > > after the first user who was set to Admin. How do I get around this or is it > > possible? > > > > I thought you could just: > > > > public boolean adminUser() { > > if(user.getUserType().equalsIgnoreCase("Admin")) { > > adminUser = true; > > setAdminUser(true); > > } > > else if(user.getUserType().equalsIgnoreCase(null)) { > > adminUser = false; > > } > > return adminUser; > > } > > > > However it never goes by the first if when the user is not an admin user.. > > > > > > -- > > View this message in context: > > http://tapestry.1045711.n5.nabble.com/Object-creator-set-to-null-tp4290653p4290718.html > > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > > For additional commands, e-mail: users-h...@tapestry.apache.org > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org