The best thing is to think of the ActionForm as a data transfer object. 
As such, it shouldn't be accessing the data service itself, but simply 
carrying the data for others to use.

The validate method is an apology to the web tier. The standard HTML 
controls will accept any String value you care to throw at them. Many 
business tier methods either expect typed values or values that will 
cleanly convert. The ActionForm validate gives you the opportunity to 
preview the input before dispatching it to the Action object. But it is 
not a recommended practice to couple business services with a Struts 
ActionForm. Better to concentrate all the business service couping in 
your Actions.

Depending on how clever the business objects are, many developers don't 
use the validate method, but do it all in the Action. This is a 
perfectly fine way to go. It all depends on what else you have going on 
in ~your~ application.

-Ted

Cohan, Sean wrote:

> We need to implement '3 strikes and your out' functionality to our logon
> process.  If the user is unsuccessful after 3 logon attempts, we disable
> their account.  I put some of the user id / password functionality in the
> validate method of the LogonForm class.  However, in between each attempt, I
> need find out what number of logon attempt they are on, and if this is not
> their 3rd attempt, bump up the logon attempt number. If it's their second
> attempt and they fail, I  need to let them know they only have 1 ore chance
> to get it right.  If they successfully logon, we also need to show them how
> many attempts it took them to logon the last time their account was
> accessed.  
> 
> We were thinking we'd store their current and previous logon attempt number
> in the DB.  My question is whether it is acceptable or common practice to
> access the DB from the validate method or should DB access only be done in
> the LogonAction class (which means I'd move the perform functionality to the
> LogonAction class)?  
> 
> Thanks.
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 


-- 
Ted Husted, Husted dot Com, Fairport NY US
co-author, Java Web Development with Struts
Order it today:
<http://husted.com/struts/book.html>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to