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)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1
    • Component/s: Framework
    • Labels:
      None
    • 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

      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.

        Activity

        Johan Hoogenboezem created issue -
        Brian K. Wallace made changes -
        Field Original Value New Value
        Component/s Framework [ 11280 ]
        Hide
        Jesse Kuhnert added a comment -

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

        Show
        Jesse Kuhnert added a comment - Client side validation has been completely rewritten. Required fields should now be properly validated no matter what type they are.
        Jesse Kuhnert made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 4.1 [ 12310632 ]
        Mark Thomas made changes -
        Workflow jira [ 12345499 ] Default workflow, editable Closed status [ 12567619 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12567619 ] jira [ 12591966 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Johan Hoogenboezem
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development