A little-publicized feature (ahem) of Struts 1.1 Validator is that arg1
has to be paired with minlength and arg2 has to be paired with
maxlength, as I understand it (last I remember this was true). I don't
know if this has been changed in more recent versions. You are pairing
maxlength with arg1 in the example posted. Also, I think the var-name
needs to be "maxlength", not "maxLength".
Erik
Shah, Akshay wrote:
Hii All,
I am using Struts 1.1, DynaValidatorForm.
The required validation is working fine.
The minlength and maxlength validations are not working for me. ie, wutever
be the case they always throw the error.
and I am completely clueless as to why is this happening. Any thoughts
Any thoughts?
Regards,
Akshay
My Source
validator-rules.xml
<validator name="maxlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMaxLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.maxlength"/>
validation.xml
<formset>
<!-- An example form -->
<form name="parentForm">
<field property="userName" depends="required,maxlength">
<arg0 key="message.username"/>
<arg1 name="maxlength"
key="${var:maxLength}" resource="false"/>
<var>
<var-name>maxLength</var-name>
<var-value>6</var-value>
</var>
</field>
</form>
</formset>
struts-en_US.xml
....
<form-beans>
<form-bean
name="parentForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="userName"
type="java.lang.String"/>
</form-bean>
<form-beans>
|
|
|
<action path="/register"
name="parentForm"
validate="true"
scope="session"
type="com.kandoo.profile.action.registerAction"
input="/profile/pages/register.jsp">
<forward name="success"
path="/en_US/home/pages/home.jsp" contextRelative="true"/>
<forward name="addChild"
path="/en_US/profile/pages/childProfile.jsp" contextRelative="true"/>
<forward name="initial"
path="/en_US/profile/pages/register.jsp" contextRelative="true"/>
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]