Dave, Here's my method that does the validation:
public static boolean validateTwoFields(Object bean, ValidatorAction va, Field field, ActionErrors errors, HttpServletRequest request) { String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); String sProperty2 = field.getVarValue("secondProperty"); String value2 = ValidatorUtils.getValueAsString(bean, sProperty2); if (!GenericValidator.isBlankOrNull(value)) { try { if (!value.equals(value2)) { errors.add(field.getKey(), new ActionMessage( "errors.twofields", value, value2)); return false; } } catch (Exception e) { errors.add(field.getKey(), new ActionMessage( "errors.twofields", value, value2)); return false; } } return true; } Here's the snippet from validations.xml. <formset> <form name="pwdForm"> <field property="pwd1" depends="required,twofields"> <arg0 key="pwdForm.password"/> <arg1 key="pwdForm.confirmPassword"/> <var> <var-name>secondProperty</var-name> <var-value>pwd2</var-value> </var> </field> </form> </formset> Here's the snippet from validation-rules.xml <validator name="twofields" classname="validators.StrutsValidator" method="validateTwoFields" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" msg="errors.twofields"/> Here's password.jsp. <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <html:html> <head> </head> <html:form action="pwdAction.do"> pwd # <html:text property="pwd1"/> <br> pwd # <html:text property="pwd2"/> <p> <html:submit>Submit</html:submit> </html:form> <font color="red"> <html:errors/> </font> </html:html> My PWDAction.java doesn't have much. But, here it is. public class PWDAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { return mapping.findForward("success"); } } Advanced thanks for your time, Kiran Dave Newton <[EMAIL PROTECTED] com> To Struts Users Mailing List 04/24/2006 04:43 <user@struts.apache.org> PM cc Subject Please respond to Re: Pluggable Validator question "Struts Users Mailing List" <[EMAIL PROTECTED] he.org> [EMAIL PROTECTED] wrote: > What am I doing wrong? > Don't know. Unfortunately showing us an action mapping isn't enough to help, since there's configuration, code, etc. involved. Dave --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ----------------------------------------- The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]