[ 
https://issues.apache.org/struts/browse/WW-600?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lukasz Racon updated WW-600:
----------------------------

    Attachment: visitor_validator.patch

Attached is patch for the form tag that enables javascript visitor validation. 
Tested on 2.1.7/2.1.8-SNAPSHOT with annotation validators. Tag decomposes 
visitor validator into a list of sub validators - this way it all existing 
javascript validators are reused.

Fixed issues:
- javascript validation for visitor validator, including nested visitors 
(supports appendPrefix)
- fixes validation for radio, checkbox, select input fields (field.value does 
not work with validation for these input fields)
- fixes validation for annotated methods (WW-2191) - when actionMethod is 
provided via form tag's action attribute FormTag returns validators for given 
method only, instead of all action's validators.

> Enable Client-side validation for visitor validations
> -----------------------------------------------------
>
>                 Key: WW-600
>                 URL: https://issues.apache.org/struts/browse/WW-600
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: XML Validators
>    Affects Versions: WW 2.1
>         Environment: JDK 1.4.2, Tomcat 5.0.27, WebWork CVS (20040721)
>            Reporter: Matt Raible
>             Fix For: Future
>
>         Attachments: visitor_validator.patch
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.

Reply via email to