This is the code for the validator form

public class ValidatorLicenciaMaestro implements Serializable{
  
        public static boolean validateLicenciaMaestro(Object
bean,ValidatorAction va, Field field,ActionMessages
errors,org.apache.commons.validator.Validator
validator,HttpServletRequest request) {
        
        String value = null;
        if (isString(bean)) {
            value = (String) bean;
        } else {
            value = ValidatorUtils.getValueAsString(bean, field.getProperty());
        }


        System.out.println("This is value for validator "+value);

        
        return false;
        
    }
    
    
    
        /**
     *  Return <code>true</code> if the specified object is a String
or a <code>null</code>
     *  value.
     *
     * @param o Object to be tested
     * @return The string value
     */
    protected static boolean isString(Object o) {
        return (o == null) ? true : String.class.isInstance(o);
    }

  
}



On 5/5/05, Niall Pemberton <[EMAIL PROTECTED]> wrote:
> Looks like the method signature you've defined in the validaot-rules.xml
> doesn't match whats actually in your java class. How about you show us
> validateLicenciaMaestro() method in the ValidatorLicenciaMaestro class?
> 
> ----- Original Message -----
> From: "Metal KoRn" <[EMAIL PROTECTED]>
> To: <user@struts.apache.org>
> Sent: Thursday, May 05, 2005 5:56 AM
> Subject: My OWN VALIDATOR
> 
> Hey guys Im having a bit of problems by applying my own validators.
> 
> The thing is that I create my validator class, for testing reasons the
> calling method returns a false, this only for checkin if the validator
> is working good.
> 
> But Im getting the following Exception.
> 
> Im using Struts 1.2.4 version  and my validator rules and validation
> XML are as the following
> 
> VALIDATOR RULES
>       <validator name="licencia"
>             classname="validator.ValidatorLicenciaMaestro"
>                method="validateLicenciaMaestro"
>          methodParams="java.lang.Object,
>                        org.apache.commons.validator.ValidatorAction,
>                        org.apache.commons.validator.Field,
>                        org.apache.struts.action.ActionMessages,
>                        javax.servlet.http.HttpServletRequest"
>               depends=""
>                   msg="errors.licencia"/>
> 
> VALIDATION
>             <field property="licencia" depends="required,licencia">
>                 <arg0  key="licencia"/>
>             </field>
> 
> my ActionForm has a "licencia" property.
> 
> Hope some one could help me with this thanx.
> 
> THE ERROR:
> **********************ENtRa a LEER XML
> ****************************************
> **********************salir a LEER XML
> ****************************************
> May 4, 2005 11:41:58 PM org.apache.struts.validator.ValidatorForm validate
> SEVERE:
> validator.ValidatorLicenciaMaestro.validateLicenciaMaestro(java.lang.Obj
> ect, org.apache.commons.validator.ValidatorAction,
> org.apache.commons.validator.
> Field, org.apache.struts.action.ActionMessages,
> javax.servlet.http.HttpServletRe
> quest)
> org.apache.commons.validator.ValidatorException:
> validator.ValidatorLicenciaMaes
> tro.validateLicenciaMaestro(java.lang.Object,
> org.apache.commons.validator.Valid
> atorAction, org.apache.commons.validator.Field,
> org.apache.struts.action.ActionM
> essages, javax.servlet.http.HttpServletRequest)
>         at
> org.apache.commons.validator.ValidatorAction.loadValidationMethod(Val
> idatorAction.java:627)
>         at
> org.apache.commons.validator.ValidatorAction.executeValidationMethod(
> ValidatorAction.java:557)
>         at
> org.apache.commons.validator.Field.validateForRule(Field.java:811)
>         at org.apache.commons.validator.Field.validate(Field.java:890)
>         at org.apache.commons.validator.Form.validate(Form.java:174)
>         at
> org.apache.commons.validator.Validator.validate(Validator.java:367)
>         at
> org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java
> :112)
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to