struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Benedict <pbened...@apache.org>
Subject Re: Struts 1.3 : Validating forms / password field
Date Fri, 22 Mar 2013 19:02:40 GMT
The best approach is to make validate() deal with syntax validation. At the
beginning of your execute() method, run business logic validation and
construct ActionErrors if your business logic fails. You really shouldn't
be trying to stuff business logic in the validate() method -- keep that for
data syntax validation only.

Paul

On Fri, Mar 22, 2013 at 1:51 PM, J.V. <jvsrvcs@gmail.com> wrote:

> I have some code that does not use the Apache commons validator plugin.
>  There is a method in LoginForm.java validate() that calls
> isPasswordValid(password) that will query the database and validate the
> password and set an error message if not, and this error message is
> retrieved in the Action and a message displayed if the password was not
> valid.
>
> What I want to do is to eliminate the 'validate()' method in all of the
> *Form.java classes and goto the Apache commons validator and enter the
> rules for the password field in an entry in validator-user.xml.
>
> With this file I can see things like minimum length etc, but how would I
> validate the password if I remove the validate() method (seems easier to do
> in code).
>
> Ideally I need a combination of leaving the validate() method there (for
> just this one case) and also have it check the requirements in the
> validator-user.xml file (check the validator.xml file first for not empty,
> min length etc) and then ultimately and finally check the entered value
> against the database.
>
> What is the best approach here for refactoring the application to remove
> all validator() methods (all of which 90% of the time check the same
> things), and go to using Apache commons validator (I need a hybrid approach
> for the password field).
>
> thanks
>
> J.V.
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<user-unsubscribe@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message