This trick won't help you specify the form name in the <html:form> tag, but
will at least help you retrieve it (which should be sufficient since your
javascript really shouldn't be written with the form name hardcoded anyway).
The <html:form> tag renders a <form> tag where the value of the name
attribute is the name of the form bean associated with the form's action. I
find this a bit limiting at times, and would like to see an optional
formName attribute for <html:form> that lets you specify a different name
for the form (defaulting to the name of the form bean if you don't specify
one). Anyway...
First, add the following to your JSP:
<%-- Get a reference to the action mapping --%>
<bean:struts id="actionMappingForTheForm"
mapping="/yourActionMappingPathGoesHere" />
<%-- retrieve the form name --%>
<bean:define id="formName" name="actionMappingForThisScreen"
property="name" type="java.lang.String" />
You can then do something like this in your JSP:
<a href="javascript:submitFormByName('<bean:write
name="formName"/>');">Click me</a>
Your JavaScript submitFormByName() function could then look something like
this:
function submitFormByName(formName)
{
document.forms[formName].submit();
}
Hope that helps.
chris
-----
P.S. Instead of hardcoding the action mapping path twice (i.e. once in the
<bean:struts> tag shown above and again in the <html:form> tag), you can
change your <html:form> tag to <html:form action="<%=
actionMappingForTheForm.getPath() %>">
> -----Original Message-----
> From: Ramu, Manjukumar [PRDUS] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 25, 2002 1:27 PM
> To: 'Struts Users Mailing List'
> Subject: RE: ERROR -- Must specify type attribute if name is specified
>
>
> How do I specify form name in JSP using <html:form> tag. I
> require this form
> name to use in Java Script.
>
>
>
> -----Original Message-----
> From: Ramu, Manjukumar [PRDUS] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 25, 2002 2:12 PM
> To: 'Struts Users Mailing List'
> Subject: ERROR -- Must specify type attribute if name is specified
>
>
> Hi,
> I am using <html:form action="/jjedslookup"
> name="jjedsform"> in JSP
> and
> <action path="/jjedslookup"
> type="com.jnj.prd.action.LdapSearchAction"
> name="ldapsearchform"
> scope="request"
> input="/jjedslookup.jsp"
> validate="false">
> </action>
>
> in Struts-Config.xml
>
> I am getting following error.
> javax.servlet.jsp.JspException: Must specify type attribute if name is
> specified
> at
> org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:840)
> at
> org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:528)
> at
> jsp_servlet.__jjedslookup._jspService(__jjedslookup.java:146)
> at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(Servle
> tStubImpl.java
> :265)
> at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(Servle
> tStubImpl.java
> :200)
> at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(W
> ebAppServletCo
> ntext.java:2495)
> at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRe
> questImpl.java
> :2204)
> at
> weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
> I appreciate your Help!
>
> -Manju
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>