Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Struts html:form not populated with a NAME attribute

843841Jun 28 2005 — edited Jun 30 2005
First posting, please be gentle.

Techs: Apache Struts, NetBeans, Windows platform (please don't laugh)

My JSP code:
<html:form action="/LoginSubmit" focus="username">
My struts-config.xml code:
<action path="/LoginSubmit" type="bookshelf.controller.action.LoginSubmitAction" 
name="loginForm" input="/WEB-INF/pages/about.jsp" 
validate="true" scope="request" />
and
<form-bean name="loginForm" type="bookshelf.controller.form.LoginForm" />
I have trimmed and weeded just about everything else from the code but when i run this page (and it does run) I am missing the NAME="loginForm" attribute from the output HTML. What I do get is:
<form method="post" 
action="/bookshelf/LoginSubmit.do;jsessionid=054FC19D371D61934151D337CA303102">
<div><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" 
value="172f47466ee8c559e4eb18fda37f4688" /></div>
I don't really mind except that the focus="username" parameter on my html:form statement causes a Javascript error, the generated Javascript is attempting to reference the form name "loginForm", ie:
<script type="text/javascript">
  var focusControl = document.forms["loginForm"].elements["username"];
  if (focusControl.type != "hidden" && !focusControl.disabled) {
     focusControl.focus();
  }
</script>
So, I know why the Javascript error is happening but I can't find any reason why the struts library isn't adding a NAME attribute to my html form. Can somebody please tell me what struts needs to generate this attribute?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2005
Added on Jun 28 2005
6 comments
542 views