Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4300

JavaScript error "Uncaught TypeError: Cannot read property 'length' of undefined" in case of CheckGroupSelector and nested forms

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.3
    • 1.5.4, 6.0.0-beta1
    • wicket
    • None
    • JDK 1.6u27, Win64, Google Chrome 15.0.x

    Description

      Full stack trace is:

      Uncaught TypeError: Cannot read property 'length' of undefined:
      (anonymous function)CheckGroupSelector-ver-1323970753862.js:35
      Wicket.CheckboxSelector.updateAllCheckboxesAbstractCheckSelector-ver-1323970753862.js:35
      (anonymous function)

      Caused by CheckGroupSelector.java:

      @Override
      protected CharSequence getFindCheckboxesFunction()
      {
      CheckGroup<?> group = getGroup();
      if (group == null)

      { throw new WicketRuntimeException( "CheckGroupSelector component [" + getPath() + "] cannot find its parent CheckGroup. All CheckGroupSelector components must be a child of or below in the hierarchy of a CheckGroup component."); }

      return "Wicket.CheckboxSelector.Group.findCheckboxesFunction('" +
      group.getForm().getMarkupId() + "','" + group.getInputName() + "')";
      }

      The generated JS will address HTML form which is attached to check group, but this element may be not a root form (which is rendered as 'div' instead of 'form' element). JS code CheckGroupSelector:js:34 "parentForm[groupName]" can be evaluated to 'undefined'. I think, that "group.getForm().getMarkupId()" should be replaced by "group.getForm().getRootForm().getMarkupId()".

      Attachments

        1. wicket-4300-fix.patch
          0.9 kB
          Alexander Morozov
        2. myproject.zip
          24 kB
          Alexander Morozov

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            amorozov Alexander Morozov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: