Tamas Szabo wrote:
 > So the whole decission comes down to:
If I think that it's more likely that the name of the form will change in
the action mapping(struts-config) than someone will add a new form
to the jsp (before my form and without observing that I have javascript functions which rely on the position of the forms in the page) then I
would use forms[0].
Otherwise I would reference the form by its name.
Is this correct?

I would say that the code that is yielded when you reference the form by name is clearer and thus better regardless and I would throw away the possibility of someone changing the name in the config file. It's more important that the code be as explicit IMO.

Note too that you aren't really defining the name of the HTML form in the config file, not explicitly anyway... that's just a by-product of using the <html:form> tag. You can simply not use those tags if you want, in which case the name of the form is strictly on your JSP. I suppose that's just an aside though :)

Isn't there a struts tag which for a given action path it gives me the
name of the associated form?

You mean the associated ActionForm? I don't think there is a tag to so that specifically, but you can get at that information by doing:

<% ActionConfig mapping = (ActionConfig)request.getAttribute( Globals.MAPPING_KEY); %>

That will give you a reference to the ActionConfig associated with the request, and you can get the form name by calling getName() on it.

Thanks,
Tamas

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


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

Reply via email to