commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dragos Ionel <dragosio...@gmail.com>
Subject issues with arg positions
Date Wed, 06 May 2009 19:08:43 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message