In your validator-rules.xml you need to identify a java classname as well as
a method which will handle that specific contingency e.g.
<form-validation>
<global>
<validator name="minlength"
classname="org.apache.struts.util.StrutsValidator"
method="validateMinLength"
methodparams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends="required"
msg="errors.minlength"/>
Martin-
----- Original Message -----
From: "yuhong Qian" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Thursday, December 08, 2005 3:15 PM
Subject: Apply multiple validator to the same field
Hello all,
I have a struts 1.1 app that I want to use Validator Framework to
validate the user input on the browser. This app will need user to enter
username and password. These two fields are both required fields and the
minlength and maxlength of password is 5 and 8.
I have myEclipse generate the validator-rules.xml, which means the
validator of "required", "minlength" and "maxlength" are generated
automatically.
And the validation.xml is like this:
....
<form-validation>
<formset>
<form name="logonForm">
<field property="username" depends="required">
<arg0 key="LOGIN.FORM.USERNAME"/>
</field>
<field property="password" depends="required,minlength,maxlength">
<arg0 key="LOGIN.FORM.PASSWORD"/>
<arg1 name="minlength" key="${var:minlength}" resource="false"/>
<arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>
<var>
<var-name>maxlength</var-name>
<var-value>8</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
When I test my app, only the "required" validator is working, and I got a
popup which says
"The user name is required. The password is required.". The problem is I
did not get any message about the minlength and maxlength validation in
the popup when I input a password with length 3 and 11.
Why only the "requred" validator work?
I appreciate for nay answer!
Lucy
---------------------------------
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]