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
Type: Bug
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
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]