velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Baker <raschar...@yahoo.com>
Subject I think I'm going around the controller
Date Wed, 18 Sep 2002 17:17:12 GMT
Here is a snippet of code from my LoginCommand class:

if ( user == null ) {
            
    ctx.put("authenticated",Boolean.FALSE);
    return CREATE_ACCOUNT;
            
} else if ( user != null &&
 !
user.getKeyCode().equalsIgnoreCase(hashedPassword)){
                    
    // bad password                       
    ctx.put("authenticated",Boolean.FALSE);
    ctx.put("user",user);
    return LOGIN;
                    
} else {
                
    //all good
    ctx.put("authenticated",Boolean.TRUE);
    ctx.put("user", user);
    return HOME;
                
}

Is there a better way to do this instead of returning
one of three templates? I'm sure there is, I can feel
it on the edge of my brain but I can't quite a handle
on it.

What if my DAO throws an exception when the user is
not found in the user table. Should LoginCommand catch
it? Or should it be propagated to the Controller?

TIA

=====
rascharles@yahoo.com
http://www.charleshbaker.com/~chb/
Hacking is a "Good Thing!"
See http://www.tuxedo.org/~esr/faqs/hacker-howto.html

__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message