[ http://issues.apache.org/struts/browse/WW-600?page=comments#action_37520 ]
Matt Raible commented on WW-600: -------------------------------- It still doesn't work if you put your validation rules on your model objects (i.e. User-validation.xml), but it does work if you put the validation rules next to your action (i.e. UserAction-validation.xml). Witness it in action with WebWork 2.2.2 at http://demo.appfuse.org/appfuse-webwork/signup.html. Source code for JSP at: http://fisheye5.cenqua.com/browse/~raw,r=1.9/appfuse/extras/webwork/web/pages/signup.jsp > Client-side validation doesn't work as advertised > ------------------------------------------------- > > Key: WW-600 > URL: http://issues.apache.org/struts/browse/WW-600 > Project: Struts Action 2 > Type: Bug > Components: Views > Versions: WW 2.1 > Environment: JDK 1.4.2, Tomcat 5.0.27, WebWork CVS (20040721) > Reporter: Matt Raible > Assignee: Patrick Lightbody > Fix For: WW 2.1.1, WW 2.1.8, 2.0.0 > > The client-side JavaScript doesn't work as advertised on: > http://wiki.opensymphony.com/display/WW/Client-Side+Validation > I have the following form: > <ww:form action="'saveUser'" validate="true" cssClass="'detail'" > method="'post'"> > This generates the following onsubmit handler: > onsubmit="return(${parameters.name}_validate())" > And the following JavaScript after the form: > <script type="text/javascript"> > function ${parameters.name}_validate() { > var form = document.forms['${parameters.name}']; > var focus = ${parameters.name}_validate_actual(); > if (focus != null) { > form.elements[focus].focus(); > if (form.elements[focus].type == 'text' || > form.elements[focus].type == 'textarea') { > form.elements[focus].select(); > } > return false; > } else { > return true; > } > } > function ${parameters.name}_validate_actual() { > var form = document.forms['${parameters.name}']; > // cannot find any applicable validators > return null; > } > </script> > If I add name="'user'" to the <ww:form>, then the JavaScript looks right, but > I get: > function user_validate_actual() { > var form = document.forms['user']; > // cannot find any applicable validators > return null; > } > I have the following in validators.xml: > <validator name="requiredstring" > > class="com.opensymphony.webwork.validators.JavaScriptRequiredStringValidator"/> > Oddly enough, XMLBuddy (in Eclipse) says that "name" must be declared. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
