commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Foure <>
Subject [validator] Using Validator outside struts
Date Fri, 07 Oct 2005 13:37:12 GMT
Hi all,

I am using commons-validator-1.1.4 outside of struts
and I have 2 questions:

1.  I am integrating the validator in a simple MVC
framework.  I have an XML file with my validator
entries as is usual.  Unfortunately, I can't define my
formset and form elements in an XML file because the
validation rules are configured in custom tags.  For
example, the minimum length of the username filed
would be defined as follows:

   <fw:text property="username" min="10"/>

My first thought was to manually populate a Form
object ever time I encountered a new form and add that
to a global ValidatorResources.  Unfortunately, the
validation rules can change from user to user because
the min can be configured using a runtime expression. 
So I can't simply add the Form to the
ValidatorResources because 2 renderings of the same
form could have different validation rules.  In an
ideal world, I would have my ValidatorResources that
contains my validator settings and then create my
Validator from this ValidatorResources and then pass
the Form in the Validator.validate() method.  This
would enable me to have a global ValidatorResources
and create a new Form object for every request. Has
anybody done something similar to what I want to do? 
Is there a way to achieve the same thing with the
existing Validator code?  If not, what do you think of
my proposed API change (i.e. overloading the validate
method to take a Form object)?

2.  Even though I am not running inside of struts, I
am planning on taking the code from 
and removing the struts code from it to generate the
same javascript that it generated so I don't have to
tweak the javascript.  My question is whether or not
the javascript generated by the JavascriptValidatorTag
will work on a portal?  If I have more than one form
on a given page and I validate both forms, will I run
into a javascript problem.  In particular, I am
concerned that the "bCancel" variable would be
declared twice (as an aside, it doesn't appear that
this variable is ever changed from its false value so
an explanation of why this is needed would be nice).


Yahoo! Mail - PC Magazine Editors' Choice 2005

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message