commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <niall.pember...@gmail.com>
Subject Re: [validator] Trouble using global constants in variable values
Date Thu, 11 Feb 2010 00:21:31 GMT
On Wed, Feb 10, 2010 at 11:46 PM, Christopher Schultz
<chris@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> All,
>
> On 2/10/2010 6:27 PM, Christopher Schultz wrote:
>> <constant-value>^.*(([0-9]+.*\p{L}+)|(\p{L}+.*[0-9]+)).*$</constant-value>
> Okay, something must be wrong with my regular expression, or now I'm
> expressing it in the XML, because when I set it to
>
>  <constant-value>^[a]+$</constant-value>
>
> ...it will allow me to enter a series of a's and validator will succeed.

You could try testing you're expression directly using
GenericValidator.matchRegexp() until you're happy it works.

http://tinyurl.com/yhe66nm

If it seems correct, but still doesn't seem to work in your Struts app
then perhaps you could write a Struts plugin to retrieve the validator
resources and display the values for the forms/fields/arguments:

http://svn.apache.org/repos/asf/struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/ValidatorPlugIn.java

> If the use of the <constant> documented anywhere? I couldn't find
> anything on the website, in the wiki, etc. I was only lucky that I
> thought of looking in the DTD to see that it was possible, and that the
> "Constant" class from way back in version 1.0.1 has been indexed by
> Google to see what the syntax was supposed to be.
>
> I'd be happy to contribute some documentation if I know what form is best.

Struts has documentation on using validator:

http://struts.apache.org/1.3.10/faqs/validator.html#ConstantsVariables

Niall

> Thanks,
> - -chris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message