Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-1496

html:form focus and focusIndex problem

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.1 RC1
    • 1.3.10
    • Tag Libraries
    • None
    • Operating System: All
      Platform: All
    • 20459

    Description

      The javascript generated when using focus and focusIndex does not account for the
      following prolblem:

      We have a radio button group that is dynamically created based on a database
      query. There may be 1 or more items in the group. In the case where a single
      item exists, the radio button does NOT have any sub-elements, so in that case we
      need to use JUST the focus attribute of the form tag. However, if the radio
      button has more than one element we need to use both the focus and the
      focusIndex attributes. It would be highly desirable to be able to always specify
      the focus attribute to the name of the radio button and if the focusIndex is NOT
      specified but sub-elements do exist, the focus is set to the "0" element for the
      control.

      EX:

      My form is "referralsToPvdReport"
      The field "selectedIndices" is a checkbox group (checkboxes with the same name)
      The checkboxes are created by iterating over a collection of database records
      and therefore the index will conditionally be present if more than one record
      needs to be rendered.

      var focusControl =
      document.forms["referralsToPvdReport"].elements["selectedIndices"];

      if (focusControl.type != "hidden") {
      if (focusControl[0])

      { focusControl[0].focus(); }

      else

      { focusControl.focus(); }

      }

      Attachments

        Issue Links

          Activity

            People

              pbenedict Paul Benedict
              snowtoad Tyler Van Gorder
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: