Form focusElement attribute not resulting in correct Javascript
---------------------------------------------------------------
Key: WW-2704
URL: https://issues.apache.org/struts/browse/WW-2704
Project: Struts 2
Issue Type: Bug
Affects Versions: 2.1.2
Environment: struts2-core-2.1.2 xwork-2.1.1 struts.ui.theme=xhtml
Reporter: Owen Berry
Priority: Minor
The Javascript generated for the focusElement attribute on a form is incorrect
as it does not include the form id as a prefix for the id of the element to
focus on. See example below.
Sample form:
<s:form id="dologin" method="post" namespace="/" action="dologin"
focusElement="username">
<s:textfield label="User" name="username" />
<s:password label="Password" name="password" />
<s:submit value="Login" />
</s:form>
Generated form tag:
<input type="text" name="username" value="" id="dologin_username"/>
Generated Javascript:
StrutsUtils.addOnLoad(function() {
var element = document.getElementById("username");
if(element) {
element.focus();
}
});
What Javascript should look like:
StrutsUtils.addOnLoad(function() {
var element = document.getElementById("dologin_username");
if(element) {
element.focus();
}
});
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.