You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dragos Ionel <dr...@gmail.com> on 2009/05/06 21:08:43 UTC
issues with arg positions
The validator is not picking up the second arg for the error:
*applicationValidation.xml*
...
<validator name="*maxLengthDetailedMessage*"
classname="ca.mpac.pi.service.validation.validators.LengthValidator"
method="validateLength"
methodParams="java.lang.Object,org.apache.commons.validator.Field"
msg="errors.length.detailed"/>
<form name="ModelValidateBean">
<field property="homoNbhd" depends="*maxLengthDetailedMessage*">
<arg position="0" key="model.homoNbhd.displayname"/>
<arg position="1" key="number.4" />
<var>
<var-name>maxLength</var-name>
<var-value>4</var-value>
</var>
</field>
*Java class*
public class LengthValidator {
...
public static boolean validateLength(Object bean, Field field) {
logger.debug("Field = " + field.toString());
String value = ValidatorUtils.getValueAsString(bean,
field.getProperty());
int maxLength = (new
Integer(field.getVarValue("maxLength"))).intValue();
return GenericValidator.maxLength(value, maxLength);
}
...}
*applicationResources.properties*
....
model.homoNbhd.displayname=Homo-Nbhd / Plan Number
errors.length.detailed=The {0} must be maximum {1} characters in length.
number.4=4
The validation works fine, but the error I get is:
*The Homo-Nbhd / Plan Number must be maximum {1} characters in length.*
Any suggestions,
thanks
Dragos