So in your validation-rules.xml you have something like...

<validator name="myValidatorRule"
    classname="myPackage.MyValidator"
             method="validateMyRule"
             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.myRule">
</validator>

In your properties file you define "errors.myRule"

In your "MyValidator" class you have something like....

     public static boolean validateMyRule(Object bean,

ValidatorAction va,
                                                               ActionErrors
errors,

HttpServletRequest request) {

        boolean invalid = .... /validation check
        if (invalid) {
            errors.add(field.getKey(), Resources.getActionError(request, va,
field));
        }

     }


----- Original Message ----- 
From: "Janarthan Sathiamurthy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 11, 2004 11:15 AM
Subject: Struts-Validation and Property file


> Hi,
>
> I am using Struts validator in my application. I have defined a properties
file that has all the error messages for my application. I have mapped this
file in my struts-config.xml file.
> I have created a new rule specific for my application. I have mapped this
in my validation-rules.xml.
> Now, in my validation-rules.xml file, i want to specify the 'msg'
parameter of the <validator> tag. I want Struts to read this ('msg'
parameter value) from the properties file that i have created(the one that
contains errors messages with key's mapped to them)
>
> Please advice me on how do achieve this ?
>
> Regards,
> Janarthan S
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Search - Find what you're looking for faster.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to