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 2002/12/09 21:13:50 UTC

DO NOT REPLY [Bug 15194] New: - Bug for focus attribute on FormTag when the control to give the focus is hidden

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=15194>.
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=15194

Bug for focus attribute on FormTag when the control to give the focus is hidden

           Summary: Bug for focus attribute on FormTag when the control to
                    give the focus is hidden
           Product: Struts
           Version: Nightly Build
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: franco.caponi@tin.it


I'm trying to use the focus attribute of the FormTag but i have found a bug 
when the control is of type hidden (my form has this control enabled only with 
some condition).
The generated code cause a Javascript client error when the control is hidden, 
because it use a not inizialized variable (focusControl[0]) to determine the 
focusControl end then call on it focus() method.
The actually generated code is this (notice also incorrect indentation for 
first if statement):
<script type="text/javascript" language="JavaScript">
  <!--
  if (document.forms["corsoModifyDynaForm"].elements["titCorso"].type !
= "hidden") 
     var focusControl = document.forms["corsoModifyDynaForm"].elements
["titCorso"];
     if (focusControl.name == null) {
         focusControl = focusControl[0];
     }
     focusControl.focus();
  // -->
</script>

I suggest that the correct code to be generated may be this, that try to assign 
the focus to the control suggested and if it is hidden, assign the focus 
to the first visible control (that is not a button) of the form. 

<!--
var focusControl = null;
if (document.forms["corsoModifyDynaForm"].elements["titCorso"].type !
= "hidden") {
	focusControl = document.forms["corsoModifyDynaForm"].elements
["titCorso"];
} else {
	var size =  document.forms["corsoModifyDynaForm"].length;
	for ( var i = 0; i< size; i++) {
		focusControl = document.forms["corsoModifyDynaForm"].elements
[i];
		if (focusControl.type != 'hidden' &&
		    focusControl.type != 'submit' &&
		    focusControl.type != 'button' ) {
			break;
		}
	}
}
focusControl.focus();
// -->

TIA

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>