Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-833

Tapestry.require_field in form.js does not cater for input type select (length property of value property does not exist)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.0
    • 4.1
    • Framework
    • None
    • JBoss 4.0.3 SP 1, Tapestry 4.0 rc3, Java 5, HtmlUnit 1.7, Rhino 1.6R2, Windows WP SP2, Eclipse 3.1

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            hoogenbj Johan Hoogenboezem
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: