You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/06/03 20:34:48 UTC

DO NOT REPLY [Bug 20459] New: - html:form focus and focusIndex problem

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20459>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20459

html:form focus and focusIndex problem

           Summary: html:form focus and focusIndex problem
           Product: Struts
           Version: 1.1 RC1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: tkv@landacorp.com


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();
    }
  }

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org