I'm trying to use the validator framework. for client and server side validations. I'm using Struts 1.1.
I have in my struts-config.xml <form-beans> <form-bean name="UserListAdmin" dynamic="true" type="com.sample.forms.SampleDynaForm"> <form-property name="test" type="java.lang.String" /> </form-bean> </form-beans> <action path="/ModifyUserList" type="com.sample.actions.UserListAdminAction" name="UserListAdmin" scope="session"> <forward name="failure" path="/UserAdmin.jsp"/> <forward name="success" path="/UserList.jsp" /> </action> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> </plug-in> a form which look like... public class SampleDynaForm extends DynaValidatorForm { /** * Constructor */ public SampleDynaForm() { super(); System.out.println("initiated a SampleDynaForm"); } public void reset(ActionMapping mapping, HttpServletRequest request) { // Reset values are provided as samples only. Change as appropriate. System.out.println("reset in SampleDynaForm"); } public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping, request); System.out.println("errors after validation:"+errors.size()); if(errors == null) { errors = new ActionErrors(); } System.out.println("errors returned:"+errors.size()); return errors; } } an action class execute method which... public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors errors = new ActionErrors(); ActionForward forward = new ActionForward(); DynaActionForm theForm = (DynaActionForm) form; // return value try { String testInput = (String)theForm.get("test"); System.out.println("testInput:"+testInput); } catch (Exception e) { // Report the error using the appropriate name and ID. System.out.println("Exception:\n"+e.toString()); errors.add("action.error", new ActionError(e.toString())); } // If a message is required, save the specified key(s) // into the request for use by the <struts:errors> tag. for(Iterator iter=errors.get();iter.hasNext();) { System.out.println("errors:\n"+iter.next()); } if(errors.isEmpty()) forward = mapping.findForward("success"); else { saveErrors(request, errors); forward = mapping.findForward("failure"); } // Finish with return (forward); } validation.xml <formset> <form name="userListAdmin"> <field property="test" depends="required"> <arg0 key="label.test"></arg0> </field> </form> </formset> JSP page <html:form action="/ModifyUserList" method="post" onsubmit="return validateUserListAdmin(this)"> <html:errors/> <table cellpadding="2" cellspacing="2" border="0"> <tr> <td><html:text property="test" /></td> </tr> <tr> <td><html:submit property="bSubmit" /></td> </tr> </tbody></table> I've copied the validation-rules.xml from the one available with the jakarta-struts-1.1.zip downloaded. The problem is that it doesn't seem to be validating on server side at all!!! I modified the validation-rule.xml javascript to return true always in the javascript method so that it gives a prompt and still goes on to submit the form. But once the form is submitted, looks like the validator framework doesn't do anything!!! Am I doing something wrong here!!! Thanks in advance for any help Nitesh