html:submit focus problem
Hi All,
I am using a struts application with JSP page.There are 2 buttons in the page and as always the 1st button is the one which is always focussed.I want to set the focus on the 2nd button.How can I achieve it.
The buttons are as follows
<html:cancel styleClass="cancel">
<bean:message key="form.cancel" />
</html:cancel>
<html:submit styleClass="submit">
<bean:message key="form.submit" />
</html:submit>
Thanks in advance.
S.N.
[538 byte] By [
snarayana] at [2007-11-26 21:19:57]

# 2
I think the issue is not actually one of "focus" but which is the "default" button invoked when you press "Enter".
Struts renders both an <html:cancel> and an <html:submit> as a standard html submit button - ie <input type="submit">
The "default" button that is invoked when you press "enter" on the form, is the first input type="submit" that it finds inside the form.
In this case, since you have "cancel" first, the cancel button will be the default.
I don't think you can change which button is "default"
To make the "submit" button the default, it has to appear first in the HTML.
If you want to display them on the page the other way around, you will have to work around this limitation.
Couple of workarounds
1 - use CSS Positioning to move the buttons around.
2 - add another <html:submit style="display:none"/> onto the page. It won't be rendered, but I think it would still count as the "default" button.
Hope this helps,
evnafets