struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Hackett" <mhack...@pictorius.com>
Subject RE: focus and Navigator 4.x
Date Fri, 30 Mar 2001 17:15:11 GMT
Ted Husted <husted@apache.org> wrote:

> Example:
>
> <table>
> <html:form action="/logon" focus="username">
> <html:text property="username" size="15" maxlength="15"
> onblur="document.logonForm.password.focus();"/>
> <tr>
> <td align="right"><font size="-1"><u>U</u>sername</font></td>
> <td>
> <html:text property="username"
> onblur="document.registerForm.password.focus();"/>

I think your example is a little messed up -- you probably meant that
first username field to be down where the second one is, and not have
the second one (which refers to a different form).

> Note that this workaround will break if the name of the form
> changes. (A simple "this.{field}.focus()" doesn't work.)

What about "this.form.elements['password'].focus()" (or just
"this.form.password.focus()")? Since your "this" would be a form field,
you need to go "up" to the form to get to another field.

> The big fix is to put the Javascript in the body tag, but that implies
> adding a <html:body> tag to
> the Struts library. The next alternative might be to extend the
> html:text tag so that it could produce the "onblur" fix automatically,
> inserting the proper form name from the struts-config file.

It would also have figure out which field to add the "onblur" fix to,
otherwise every field would have to have the code. Plus, Struts would
need to know what field to go to next (possibly having to interpret
taborder attributes). Sounds messy!

I think the <body> fix is probably better -- probably more reliable and
definitely simpler to implement. The html:form tag doesn't have to
change much (just generate a function to set the focus instead of inline
immediate code) and we just have to add a simple html:body tag that
invokes the function, along with any other "onload" code defined in the
tag. Doesn't sound too bad to me. Thoughts?

--
Michael Hackett
Developer, Pictorius Inc.


Mime
View raw message