Leo, You could also check out Niall's server-side validator add-on to "extend" a field. Be aware that doesn't work for client-side Javascript or any version before 1.2.X. http://www.niallp.pwp.blueyonder.co.uk/strutsvalidatorextends.html Again, his extension does allow for adding different 'groups' (one or more from what I've read) of validations to any <?form....?><?/form?> set.
Regards, David -----Original Message----- From: Leo Asanov [mailto:[EMAIL PROTECTED] Sent: Sunday, September 04, 2005 10:56 PM To: Struts Users Mailing List Subject: Re: Re-use field validations? Hi! I was looking for this kind of functionality some time ago and didn't find any standard way of doing reusable validators. What I did was more like a hack, but it worked: 1. For server side validation. Overwrite validate() method of FormBean class with something like this: public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) { ServletContext application = getServlet().getServletContext(); ActionErrors errors = new ActionErrors(); String validationKey = "validationNameIn Validation.xml"; Validator validator = Resources.initValidator(validationKey,this,application, request,errors, page); try {validatorResults = validator.validate();} catch (ValidatorException e) { logger.error(e.getMessage(), e); } return errors; } Just change validationKey to whatever is in your validation.xml. 2. Client-side validation. Put the following code at the top of your page: <script type="text/javascript"> var realFormName_required=formNameFromValidationXMLFile_required; </script> Again replace "realFormName" with the form name how it appears in your struts-config.xml. And replace "formNameFromValidationXMLFile" to the validator name (should be the same one you used for server-side validation). Hope this will help. Cheers, Leo > Quinn Stone wrote: > > Is there any way to define the validation for a > common form field once in > > validation.xml and re-use the validation in other > <form> blocks? __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- 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]