Just sharing a simple test I just did.

It looks that you can't have two forms with the same name on one document.
I created a page with two forms with the same name, then checked how the
browser sees them with a quick javascript:

var result = "Forms in this document:\n\n";
for (var i=0; i < document.forms.length; i++) {
    result = result + "document.forms[" + i + "]=" + document.forms[i] +
"\n";
    result = result + "document.forms[" + i + "].name=" +
document.forms[i].name + "\n\n";
}
alert(result);

There was only one entry for the two similarly named forms.  Checking the
fields of the form showed me that only the latest definition of a form with a
given name is recognized.

So, you should probably add a formbean declaration (with a different name)
for your action form, and also add another mapping for the same action.  It
can be the same ActionForm and Action object, but would need different
mappings in struts-config.

- Hubert

--- Jacob Weber <[EMAIL PROTECTED]> wrote:

> 
> I have a JSP with two forms, and they both need to go to the same 
> action. But Struts assumes that the "name" property of the HTML form 
> (e.g. <FORM NAME="MYFORM">) should be the same as the name of the 
> associated form bean. As a result, I can't use JavaScript to refer to 
> one of the forms, since they both have the same name.
> 
> Is this a situation where I need to write my own version of <html:form>? 
> Why does Struts make this assumption?
> 
> Things I've already considered:
> 
> - Using two different actions with different form beans. This doesn't 
> work, since the JSP needs to refer to the form bean by name (for 
> example, in <bean:write>). If I use two actions that return the same 
> JSP, they need to use the same form bean.
> 
> - Combining the two forms into one. This doesn't work in my situation, 
> since the forms need to submit different values for the same fields.
> 
> - Referring to the forms by number in my JavaScript (e.g. 
> document.forms[0]). This doesn't work, since there may be other forms on 
> the page, which would throw off the numbering.
> 
> Any ideas?
> Thanks,
> Jacob
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to