You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org> on 2006/07/23 17:16:14 UTC

[jira] Resolved: (TAPESTRY-833) Tapestry.require_field in form.js does not cater for input type select (length property of value property does not exist)

     [ http://issues.apache.org/jira/browse/TAPESTRY-833?page=all ]

Jesse Kuhnert resolved TAPESTRY-833.
------------------------------------

    Fix Version/s: 4.1
       Resolution: Fixed

Client side validation has been completely rewritten. Required fields should now be properly validated no matter what type they are.

> Tapestry.require_field in form.js does not cater for input type select (length property of value property does not exist)
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-833
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-833
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.0
>         Environment: JBoss 4.0.3 SP 1, Tapestry 4.0 rc3, Java 5, HtmlUnit 1.7, Rhino 1.6R2, Windows WP SP2, Eclipse 3.1
>            Reporter: Johan Hoogenboezem
>            Priority: Minor
>             Fix For: 4.1
>
>
> I'm building unit tests for my Tapestry application using HtmlUnit (and Rhino to handle the JavaScript). When submitting a form with "required" validation set up for a Select component I get the following exception:
> org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from null
> ...stack trace goes here...
> I tracked it down to line number 109 in form.js:
> line 105:Tapestry.require_field = function(event, fieldId, message)
> line 106:{
> line 107:    var field = this.find(fieldId);
> line 108:    
> line 109:    if (field.value.length == 0)
> line 110:      event.invalid_field(field, message);
> line 111:}
> I changed the function to the following:
> Tapestry.require_field = function(event, fieldId, message)
> {
>     var field = this.find(fieldId);
>     if (field.type == "select-one" || field.type== "select-multiple") {
>       if (field.selectedIndex == -1)
>         event.invalid_field(field, message);
>     }
>     else {
>       if (field.value.length == 0)
>         event.invalid_field(field, message);
>     }
> }
> This resolves the issue for my scenario.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org